Sign inSign up

CS — Algorithms & Complexity · Week 1–4

#cs#algorithms#exam
Big-O, sorting, searching, recursion. ·by Priya Patel· 29 copies ·4.3(3)
3 reviews
Flashcards
Computer Science key terms
5 cards
Quiz
Computer Science quiz
4 questions

Big-O notation

Big-O describes growth in the worst case, ignoring constants: O(1)⊂O(log⁡n)⊂O(n)⊂O(nlog⁡n)⊂O(n2)O(1) \subset O(\log n) \subset O(n) \subset O(n \log n) \subset O(n^2).

Sorting

Merge sort is O(n log n) always; quicksort is O(n log n) on average but O(n²) worst case; bubble sort is O(n²).

Binary search

Halving a sorted array each step gives O(log⁡n)O(\log n) comparisons. It is naturally recursive.

Reviews
4.3(3)Sign in to review