Linear search: An array is looped through. Inside the for loop, an if statement checks for the searchitem. If the search item is found the loop breaks.
Binary Search:
start=0
end=4
found=false
while (found==falseANDstart<=end)
midpoint= (start+end) DIV2
if (num[midpoint] ==item) then
found=true
elseif (num[midpoint] >item)end=midpoint-1
else
start=midpoint+1
endif
endwhile
A*: A faster version of Dijkstra. Uses heuristics to reach the goal node only, unlike Dijkstra which finds the shortest path to every node. Used when speed is more important than accuracy.
Dijkstra: Iterativepathfinding algorithm which finds the shortestpath in a graph. Node / Visited / Cost / PrevyNodes
Costs are all set to infinity initially --> While there are unvisited nodes, you find the one with the lowestcost, and for each unvisitedneighbour you calculatethenewcost.
Time complexity:
How much time an algorithm requires to solve a particular problem. Is measured by big-o notation, and shows the effectiveness of the algorithm.
It shows the amount of timetakenrelative to the number of dataelements given as an input.
Binary Big O Notation:
Best = O(1)
Average = O(logn)
Worst = O(logn)
Insertion Big O Notation:
Best = O(n)
Average = O(n^2)
Worst = O(n^2)
Linear Big O Notation:
Best = O(1)
Average = O(n)
Worst = O(n)
Bubble Big O Notation:
Best = O(n)
Average = O(n^2)
Worst = O(n^2)
Space complexity:
Is the amount of storage the algorithm takes. It is also expressed using Big O Notation. They store extra data whenever they make a copy, and this can get expensive in big datasets.