Identify two problems in each category of the following time complexities and derive the complexity of these identified problems. (4+6 marks) O(n log n), and O(n2 ).
O(n log n): Comparison sort, Fast Fourier transform
O(n): Bubble sort, Insertion sort
Comparison sort: you must look at every element which is O(n). For each of those elements you look at, you must find out if its in the right order, which is at best O(log n) (binary search for example). So the net sum becomes O(n log n).
Fast Fourier transform: every sum has complexity. The number of iterations: So, every step has the complexity . We have steps, so the complexity of algorithm will be .
Comments