A measure of time, memoryspace or resources needed for an algorithm increases as the data size it works on increases.
Big-O Notation
Mathematicalnotation used to describe the worst case, average case and best case scenarios of the performance of an algorithm. It provides a way of identifying which algorithm has the best time-complexity and which has the bestspace-complexity.
Constant Complexity
The timetaken for an algorithm to run is independent of the number of items in the data set. For example, printing the first letter in a string will take sameamount of time, regardless of the length of the string.
Linear Complexity
Timetaken for an algorithm to run fully increases at the samerate at which the number of items in the data set increases. For example, doubling the number of items in a data set will double the time to find the largestnumber.
Polynomial Complexity
Timetaken for an algorithm to run fully increases proportionally to n raised to the power of a constant.
Exponential Complexity
Timetaken to run an algorithm completely is proportional to the a constant raised to the power of n. This model doesn't scale up well as with largervalues of n,timetaken for the algorithm to compute will take exponentiallylonger.
Logarithmic Complexity
Timetaken for an algorithm to run completely is proportional to a logarithmicfunction of n. This is the mostidealcomplexity for any algorithm which has been scaled up as it means that at increasinglylargevalues of n, timetaken is essentially constant.
Bubble Sort
Moves through the datasetrepeatedly in a linearfashion, swappingtwoitems that have been compared if the the first is larger than the second.Intuitive and easy to program but inefficient. Best Case: Constant. Average Case: Polynomial. Worst Case: Polynomial.
Insertion Sort
Dividing a dataset into twoarrays: sorted and unsorted.Elements are inserted into there correct positions in the sortedarray as they are reached in the unsortedarray.Simple but inefficient. Best Case: Constant. Average Case: Polynomial. Worst Case: Polynomial.
Merge Sort
Splits a datasetnterms long into nnumber of datasets each oneitemlong. These are merged into ordereddatasets2nitemslong, then ordered datasets 4n data items long. This continued till you have oneordereddataset.Recursive function uses morememory.Fast and efficient with largevalues of n but difficult to program. Best Case: Logarithmic. Average Case: Logarithmic. Worst Case: Logarithmic.
Quick Sort
Picks an items as a "pivot". It creates twolists on eitherside of thepivot: those bigger than the pivot remain on the right while those lower than the pivot get moved to the left. When this is completed a newpivot is selected and the processrepeats till dataitemn is less than dataitem n+1.Recursivefunctions is used so harder to program. Very quick for largedatasets.Initialarrangement of data is important. Best Case: Logarithmic. Average: Logarithmic. Worst: Polynomial.
A* Algorithm
A* Search improves on Dijkstra'salgorithm by estimating the distance to the finalnode using a heuristic, finding the shortestpathfaster. It combines the distance from the startnode and the heuristic estimate to the endnode to choose the nextnode. It explores adjoiningnodes but may backtrack if needed for a betterpath.
Dijkstra's Shortest Path Algorithm
Finds the shortest path between two nodes on a
graph. It works by keeping track of the shortest distance to each node from the starting node. It
continues this until it has found the destination node.
Binary Search
Binarysearchhalves the searchspace by comparing the targetvalue with the middleelement of a sortedarray and recursivelysearching the left or right half until finding the target or exhausting the array.
Linear Search
Linear search checks each element in a listsequentially until finding the target or exhaustingsearchspace.
Queues
Managing tasks in a multitaskingenvironment, such as an OSscheduler. Follows FIFO principle, making them suitable for scenarios where the tasks must be processed in the order that they arrive.
Stacks
Functioncalls and recursion tracking in programminglanguages. Follows a LIFO principle, making them suitable for tracking nested functioncalls and local variablestorage. Stacks can also be used to undo/redooperations in various applications.
Trees
Representing hierarchicaldatastructures like file systems or organisationalcharts.Binary Search Trees are best for efficientsearching and sorting of data.
Graphs
Modellingrelationships between objects, such as socialnetworks or networkrouting.Shortest path algorithms used to find shortestdistance between twonodes in a graph.
Binary Trees
Each node has maximum2nodes. Efficient sorting and searching algorithms. Used to organisedata sets and expression trees used to represent mathematicalexpressions.
Multi-branch Trees
Each node can have more than 2 nodes. Representing hierarchicalrelationships becomes more flexible. Used where directories contain multiplefiles and subdirectories.
Search for a specific node in the tree.Systematicallyperform an operation at each node of the tree. Navigate the hierarchy of file systems or organisational charts systematically to find specific nodes.
Linked Lists
Stores data in a data setnon-contiguously and uses pointers to link the data items together.