CST370 Week 5

This week I learned how several important algorithms actually work step by step. Quicksort uses divide and conquer by choosing a pivot, then moving smaller elements to the left and bigger ones to the right through partitioning with two pointers. After that, it recursively sorts both sides. Median of three improves it by picking a better pivot from the first, middle, and last values. Binary search works by checking the middle of a sorted list and cutting the search space in half each time. For trees, preorder visits root first, inorder visits root in the middle, and postorder visits root last. Kahn’s algorithm removes nodes with zero in degree to build a topological order.


Discussion & Comments