Computational Thinking and Problem
Computational Thinking and Problem
solving
Big O Notation
Big O notation is used used as a tool to describe the growth rate of a function in terms of the
number of instructions that need to be processed (time complexity) or the amount of memory
Note: Two algorithms can have the same Big O notation but in practice have wildly different
execution times in practice. This is because the Big O describes the growth rate of complexity,
Time Complexity
Time complexity refers to the growth in the number of instructions executed (and therefore the
Space Complexity
Space complexity refers to the growth in the size of memory space that is required as the
1
MUHAMMAD WASEEM SABRI
Algorithm Performance
There are a number of factors that affect the performance of search / sorting algorithms. Some
algorithms perform well with high entropy (randomness) data, other algorithms work better
when the data is partially sorted in some manner. This means that no one algorithm works best
in every situation and the nature of the data being sorted needs to considered.
Advertisement
Search Algorithms
Merge Sort
Repeatedly merge sub-lists to produce new sorted sub-lists until there is only one sorted list
2
MUHAMMAD WASEEM SABRI
Insertion Sort
removes one element from the input data, finds the location it belongs within the sorted list,
Bubble Sort
3
MUHAMMAD WASEEM SABRI
Lighter bubbles rise to the top, Heavier ones sink to the bottom.
Recursion
Sub-problems are the same kind as the original problem and they can be solved with the same
algorithm Simpler to solve: sub-problems are so simple that they can be solved without further
It needs at least one base case to stop recursive calls otherwise the program will crash.
4
MUHAMMAD WASEEM SABRI