- Show that is . Justify your answer with a proof.
- Show that is . Justify your answer with a proof.
- Show that is . Justify your answer with a proof.
- Prove by induction that is divisible by for every non-negative integer n.
- According to this reference, the Bubble Sort algorithm has a worst case time complexity of , but a best case time complexity of . Does this mean that Bubble Sort is more performant than an algorithm like Quicksort with a worst case and best case complexity of ? Why don’t we just use Bubble Sort in large systems, all the time?
- Suppose I create a data structure called
MyCoolStructure
which has four operations. Each of the operations runs in O(1) time:
MyCoolStructure mcs;
mcs.insert_first(x); // inserts "x" at the front of the structure
mcs.insert_last(x); // inserts "x" at the end of the structure
mcs.delete_first(); // deletes the element at the front of the structure and returns it to the user
mcs.delete_last(); // deletes the element at the end of the structure and returns it to the user
Write the pseudocode for a function called void swap_ends(MyCoolStructure mcs)
which swaps the first and last items in the data structure. What is the Big- time complexity of this function?