Programming Foundations Algorithms With Python

Overview

Programming-Foundations-Algorithms

Algorithms purpose

to solve a specific proplem with a sequential sets of steps for instance : if you need to add different shaped in groups you can use loop by iterate on each shape if its belong to this group or not

Algorithms charachteristics

  • algorithms complixity
    • space complixity
    • time complixity
  • input and output
  • classification
    • serial/parallel
    • exact/approximate

common algorithms

  • searching algo find a specific data from a structure
  • sorting algo take a set of data and apply a sort order to it
  • computational algo given a ser of data calculate another (calculator)
  • collection algo work with collection of data : manipulating and navigating amoung sets of data that are sorted (count a specific items) exerciese for an algorithm
def greatest common denomonator (a,b)
    while (b != 0)
        t=a
        a=b
        b=t%b
    return a 

print(20,8)

Algorithm performance

  • how an algorithm will be have based on the size of input set data
  • big-O to describe algorithm performance as the size of input grows over time it usually describe the worst case senario

Time complixity rank

  • O(1) operation in question doesnt depend on the number of elements in the given data set (calculating the number is even or odd)
  • O(log n) finding a specific value in a sorted array using a bionary search so if the number of elements grow it takes logarithmic time relation to find any given item
  • O(n) searching for an item in an unsorted array as number of items increase it take the corrosponding linear time to complete the search
  • O(nlogn) sorting algorithm like stack and merge sort
  • O(n2) as the number of data increase the time it take is squared

Overview on Data structure

1: Array

it has either one dimention or multiple , you can calculate

  • item index O(1)
  • insert or delete at beginning or middle O(n)
  • insert or delete at end : O(1)

2: Linked lists(nodes)

  • linear collection of data elements each node has a field that refer to the next element in the list
  • the benifit of it over arrays is that its fast and easy to add and remove items from the list
  • its not necessary to recognize the essintial memory that hold the data because the individual nodes doesnt have to be stored adjecently like arrays
  • the linked lists cant do canstant time random access to any item in the list like the array

**you can inserting a new item in the list**

#### 3: stack **is collection that support two priciples .** * push * pop the last item pushed is the first one poped

is used in * expression processing * back tracking #### 4: Queue **its collection that supports adding and removing and work like stack but** the first item added is the first one removed

is used in * order processing * massaginh #### 5: hash tables **an ability to unique map a given key to a specific value (word during dictionary list)**

it * is very fast * for small data sets array is more efficient * hash table dont order entries in a predictable way ___ ### Recursion * your recursive function return at some point (breaking condition) * otherwise it leeds to infinite loop * each time the function called the value of arguments of the previous call are stored aside not written over by the new call (call stack) ### sorting data ####1: bubble sort

its

  • very simple to understand and implement
  • performance O(n2)
    • for loops inside of for loops are usually n2
  • other sorting algorithms are generally much better

2: merge sort

by

  • divide and conquer algorithm
  • breaks a dataset into individual pieces and merges them
  • uses recursion to operate on datasets its
  • performs well on large sets of data
  • generally has O(nlogn) performance

3: Quicksort

  • divide and conquer algorithm
  • uses recursion to operate on datasets
  • generally has O(nlogn) performance
  • operate in place on the data
  • worst case is O(n2) when data is mostly sorted already

searching data

  • unordered list search
  • ordered list search
  • determine if alist is sorted

other algorithms

  • filtering hash table
  • counting value with hash table
  • find max value recusively
Owner
omar nafea
omar nafea
A library for benchmarking, developing and deploying deep learning anomaly detection algorithms

A library for benchmarking, developing and deploying deep learning anomaly detection algorithms Key Features • Getting Started • Docs • License Introd

OpenVINO Toolkit 1.5k Jan 04, 2023
TikTok X-Gorgon & X-Khronos Generation Algorithm

TikTok X-Gorgon & X-Khronos Generation Algorithm X-Gorgon and X-Khronos headers are required to call tiktok api. I will provide you API as rental or s

TikTokMate 31 Dec 01, 2022
Genetic algorithm which evolves aoe2 DE ai scripts

AlphaScripter Use the power of genetic algorithms to evolve AI scripts for Age of Empires II : Definitive Edition. For now this package runs in AOC Us

6 Nov 04, 2022
RRT algorithm and its optimization

RRT-Algorithm-Visualisation This is a project that aims to develop upon the RRT

Sarannya Bhattacharya 7 Mar 06, 2022
N Queen Problem using Genetic Algorithm

The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other.

Mahdi Hassanzadeh 2 Nov 11, 2022
Visualisation for sorting algorithms. Version 2.0

Visualisation for sorting algorithms v2. Upped a notch from version 1. This program provides animates simple, common and popular sorting algorithms, t

Ben Woo 7 Nov 08, 2022
A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines

py-earth A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines algorithm, in the style of scikit-learn. The py-earth p

431 Dec 15, 2022
Parameterising Simulated Annealing for the Travelling Salesman Problem

Parameterising Simulated Annealing for the Travelling Salesman Problem Abstract The Travelling Salesman Problem is a well known NP-Hard problem. Given

Gary Sun 55 Jun 15, 2022
A Python description of the Kinematic Bicycle Model with an animated example.

Kinematic Bicycle Model Abstract A python library for the Kinematic Bicycle model. The Kinematic Bicycle is a compromise between the non-linear and li

Winston H. 36 Dec 23, 2022
A python implementation of the Basic Photometric Stereo Algorithm

Photometric-Stereo A python implementation of the Basic Photometric Stereo Algorithm Result Usage run Photometric_Stereo.py Code Tree |data #原始数据,tga格

20 Dec 19, 2022
A lightweight, object-oriented finite state machine implementation in Python with many extensions

transitions A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+. Installa

4.7k Jan 01, 2023
implementation of the KNN algorithm on crab biometrics dataset for CS16

crab-knn implementation of the KNN algorithm in Python applied to biometrics data of purple rock crabs (leptograpsus variegatus) to classify the sex o

Andrew W. Chen 1 Nov 18, 2021
A priority of preferences for teacher assignment problem

Genetic-Algorithm-for-Assignment-Problem A priority of preferences for teacher assignment problem Keywords k-partition; clustering; education 4.0 Abst

hades 2 Oct 31, 2022
Algorithm and Structured Programming course project for the first semester of the Internet Systems course at IFPB

Algorithm and Structured Programming course project for the first semester of the Internet Systems course at IFPB

Gabriel Macaúbas 3 May 21, 2022
This project consists of a collaborative filtering algorithm to predict movie reviews ratings from a dataset of Netflix ratings.

Collaborative Filtering - Netflix movie reviews Description This project consists of a collaborative filtering algorithm to predict movie reviews rati

Shashank Kumar 1 Dec 21, 2021
An NUS timetable generator which uses a genetic algorithm to optimise timetables to suit the needs of NUS students.

A timetable optimiser for NUS which uses an evolutionary algorithm to "breed" a timetable suited to your needs.

Nicholas Lee 3 Jan 09, 2022
Python based framework providing a simple and intuitive framework for algorithmic trading

Harvest is a Python based framework providing a simple and intuitive framework for algorithmic trading. Visit Harvest's website for details, tutorials

100 Jan 03, 2023
Code for generating alloy / disordered structures through the special quasirandom structure (SQS) algorithm

Code for generating alloy / disordered structures through the special quasirandom structure (SQS) algorithm

Bruno Focassio 1 Nov 10, 2021
This is the code repository for 40 Algorithms Every Programmer Should Know , published by Packt.

40 Algorithms Every Programmer Should Know, published by Packt

Packt 721 Jan 02, 2023
Distributed Grid Descent: an algorithm for hyperparameter tuning guided by Bayesian inference, designed to run on multiple processes and potentially many machines with no central point of control

Distributed Grid Descent: an algorithm for hyperparameter tuning guided by Bayesian inference, designed to run on multiple processes and potentially many machines with no central point of control.

Martin 1 Jan 01, 2022