Docsity

Advanced Data Structures Cheat Sheet for Computer Science, Cheat Sheet of Computer Science

Partial preview of the text

Download Advanced Data Structures Cheat Sheet for Computer Science and more Cheat Sheet Computer Science in PDF only on Docsity!

Theoretical Computer Science Cheat Sheet – Advanced Data Structures CS 6310 Study Notes | Data Structures and Algorithms Student’s name Institution Course code Professor Date

Theoretical Computer Science Cheat Sheet – Advanced Data Structures CS 6310 Study Notes | Data Structures and Algorithms

  1. Trees and Tree-Based Structures Binary Search Trees (BSTs) Definition: Each node has a key, left child is less than the node, and the right child is greater than the node. Average time complexity: Search, Insert, Delete: O(log n) Worst-case (unbalanced): O(n) AVL Trees Self-balancing BST with height difference (balance factor) of 1 or less. Rotation operations include Left, Right, Left-Right, and Right-Left. Guarantees O(log n) time for search, insert, and delete. Red-Black Trees Balanced BST where nodes are colored red or black. Ensures no path is more than twice as long as any other path.

Extract-min/max: O(log n) Heapify: O(n) Fibonacci Heaps Improved amortized time: Insert: O(1) Extract-min: O(log n) amortized. Used in Dijkstra’s algorithm, especially with large graphs.

  1. Hashing and Hash Tables Hash Tables Average case: O(1) for search, insert, and delete. Collisions are resolved by: Chaining: Linked lists. Open addressing: Linear probing and quadratic probing.

Perfect Hashing Two-level hashing minimizes collisions. Useful in static datasets, such as compiler symbol tables. Universal Hashing Reduces worst-case scenarios. Randomly selects hash functions from a family.

  1. Tries and Suffix Structures Tries (Prefix Trees) Tree where each edge represents a character. Fast lookups for strings: O(m), where m is the length of the string. Space: O(ALPHABET_SIZE × n) Suffix Trees Compressed trie of all suffixes of a string. Enables fast pattern matching in O(m). Space: O(n)

Union by rank. Time complexity is nearly O(1) with Ackermann’s function.

  1. Advanced Structures and Techniques Skip Lists Probabilistic alternative to balanced trees. Layers of linked lists. Average time: O(log n); space: O(n). Treaps BST and heap properties combined. Balanced by assigning random priority. Expected time: O(log n). B-Trees and B+ Trees Used in databases and file systems. Maintains sorted data with multi-way branching.

B-Trees contain keys in internal nodes. B+ Trees store all keys in leaf nodes for faster range queries.

  1. Amortized Analysis Techniques Aggregate Method: Total cost of operations divided by the number of operations. Accounting Method: Assigns "credits" to cover costly operations. Potential Method: Uses a potential function to track changes.
  2. Applications and Algorithms Dijkstra's Algorithm uses a Fibonacci heap for finding the shortest paths. Prim’s Algorithm uses a min-heap for finding minimum spanning trees. Kruskal’s Algorithm utilizes Union-Find to detect cycles. Aho-Corasick combines tries and failure links for multiple pattern matching. Bloom Filters serve as a probabilistic structure for quick membership tests.
  3. Time and Space Complexities Table

References Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to algorithms (3rd ed.). MIT Press. Weiss, M. A. (2013). Data structures and algorithm analysis in Java (3rd ed.). Pearson Education. Sedgewick, R., & Wayne, K. (2011). Algorithms (4th ed.). Addison-Wesley. Tarjan, R. E. (1983). Data structures and network algorithms. Society for Industrial and Applied Mathematics.