Docsity

CSE310 Final Review: Algorithms and Data Structures, Cheat Sheet of Computer Science

Partial preview of the text

Download CSE310 Final Review: Algorithms and Data Structures and more Cheat Sheet Computer Science in PDF only on Docsity!

CSE310 Final Review

Materials covered

  • Anything from Test 1, 2, and
  • Quiz 5-
  • Recitation 5-
  • Assignment 4-

Asymptotic

Notation

General rule:

● Constant

● Logarithms

○ log(log(n)), log(n), log2(n)

● Linears

● Polynomials

○ n^2, n^

● Exponential

○ (3/2)^n, 2^n, n2^n

● Factorials

○ (log(n))!, n!

Divide and Conquer

Merge Sort: T(n) = 2T(n/2) + Ө(n) T(n/2) for left T(n/2) for right Ө(n) for merge Recursion Tree gets you 2k(c(n/2k) + b) *On next slide

Priority Queue

Heaps

Counting Sort

Running time = Ө(n)

Stable and unstable sorting algorithms:

5

Median and Order Statistic

Order Statistic ith order statistic is the ith smallest element in A[1…n]

Hash Tables

Hash by division: h(k) = k mod m (k is key, m is table size) Hash by multiplication: h(k) = floor(m = (k * A mod 1)) Open Addressing - all elements stored inside hash table stored directly (no linked list)

Linear probe (m probe sequences)

  • h’(k) = ordinary hash function
  • h(k, i) = (h’(k) + i) mod m Quadratic probe (m probe sequence)
  • h(k, i) = (h’(k) + c1i + c2i2) mod m Double hashing (m2 probe sequence)
  • h1(k) and h2(k)
  • h(k, i) = (h1(k) + i*h2(k)) mod m

Binary Search Trees

RBT Insertion

RBT Deletion