MCQs
Although any given solution to an NP-complete problem can be validated quickly in polynomial time; there is no way to efficiently locate a solution to begin with. The unique characteristic of NP-complete problems is that no fast solution to them is known and hence NP-complete problems are said to be non-deterministic polynomial time.
Selection sort creates a sub-list, LHS of the 'min' element is already sorted and RHS is yet to be sorted. Starting with the first element the 'min' element moves towards the final element.
In the average case, even if the input is partially sorted, selection sort behaves as if the entire array is not sorted. Selection sort is insensitive to input.
Bubble sort works by starting from the first element and swapping the elements if required in each iteration.
As the input size increases, the performance of selection sort decreases.
Even though the first two elements are already sorted, bubble sort needs 4 iterations to sort the given array.
The array is partitioned into equal halves, using the Divide and Conquer master theorem, the complexity is found to be O(nlogn).
Bubble sort is one of the simplest sorting techniques and perhaps the only advantage it has over other techniques is that it can detect whether the input is already sorted.
The call to partition returns 1 and 3 as the pivot elements.
A varation of this pancake is with burnt pancakes. Here each pancake has a burnt side and all pancakes must, in addition, end up with the burnt side on bottom. It is a more difficult version of the regular pancake problem.