Exam Review Lecture

Different Iterators do different things, ss

No Pairing Heaps, no Union Find on Exam

Queue using 2 Stacks

void dequeue() {
    if (stack2.empty())
        while(!stack1.empty())
            stack2.push_back(stack1.top());
            stack1.pop();
    stack2.pop();    
}

Which sort is best?

  • Array almost already sorted: Bubble, Insertion
  • Very small array: Insertion
  • Medium size array: QuickSort, HeapSort, MergeSort (merge requires external memory)
  • Large array: QuickSort, HeapSort
  • Very large tape drive: MergeSort
  • Few unique values BucketSort, CountingSort
  • Swap/Move is expensive Selection, if ignoring complex sorts

Learn ternary, counts as 1 line!

results matching ""

    No results matching ""