PROJECTENGRAM

[REV] CCDSALG COMPREHENSIVE FINALS REVIEWER

Tags: #◇Computer Science #◇CCDSALG #◇Data Structures #◇Algorithms #◇Reviewer #◇Finals


CCDSALG Comprehensive Finals Reviewer

◇Overview

This reviewer synthesizes Data Structures and Algorithms (CCDSALG). It encompasses asymptotic complexity analysis (O,Ω,ΘO, \Omega, \Theta), linear data structures (arrays, singly/doubly linked lists, stacks, queues), nonlinear structures (trees, binary search trees, self-balancing AVL trees, binary min/max heaps), hash tables with collision resolution strategies, and graph theory algorithms (BFS, DFS, Dijkstra, Prim, Kruskal).


◇1. Master Asymptotic Complexity Matrix

Data Structure / AlgorithmAccess / SearchInsertionDeletionSpace Complexity
Array (Dynamic)O(1)O(1) / O(n)O(n)O(n)O(n) (amortized O(1)O(1) at end)O(n)O(n)O(n)O(n)
Singly Linked ListO(n)O(n)O(1)O(1) (at head)O(1)O(1) (if node given, else O(n)O(n))O(n)O(n)
Stack / QueueO(n)O(n)O(1)O(1) (push / enqueue)O(1)O(1) (pop / dequeue)O(n)O(n)
Hash TableO(1)O(1) avg / O(n)O(n) worstO(1)O(1) avg / O(n)O(n) worstO(1)O(1) avg / O(n)O(n) worstO(n)O(n)
Binary Search TreeO(h)→O(n)O(h) \to O(n) worstO(h)→O(n)O(h) \to O(n) worstO(h)→O(n)O(h) \to O(n) worstO(n)O(n)
AVL TreeO(log⁡n)O(\log n) guaranteedO(log⁡n)O(\log n) guaranteedO(log⁡n)O(\log n) guaranteedO(n)O(n)
Binary HeapO(1)O(1) peek min/maxO(log⁡n)O(\log n)O(log⁡n)O(\log n) extract min/maxO(n)O(n)

Sorting Algorithms Comparison

AlgorithmBest TimeAverage TimeWorst TimeSpaceStable?
Bubble / Insertion SortO(n)O(n)O(n2)O(n^2)O(n2)O(n^2)O(1)O(1)Yes
Merge SortO(nlog⁡n)O(n \log n)O(nlog⁡n)O(n \log n)O(nlog⁡n)O(n \log n)O(n)O(n)Yes
Quick SortO(nlog⁡n)O(n \log n)O(nlog⁡n)O(n \log n)O(n2)O(n^2)O(log⁡n)O(\log n)No
Heap SortO(nlog⁡n)O(n \log n)O(nlog⁡n)O(n \log n)O(nlog⁡n)O(n \log n)O(1)O(1)No

◇2. AVL Tree Balance Factor & Rotations

The balance factor of a node NN is defined as:
BF(N)=height(N.left)−height(N.right)∈{−1,0,1}BF(N) = \text{height}(N.\text{left}) - \text{height}(N.\text{right}) \in \{-1, 0, 1\}

  • LL Imbalance   ⟹  \implies Single Right Rotation on ZZ.
  • RR Imbalance   ⟹  \implies Single Left Rotation on ZZ.
  • LR Imbalance   ⟹  \implies Double Rotation: Left Rotate on child YY, then Right Rotate on ZZ.
  • RL Imbalance   ⟹  \implies Double Rotation: Right Rotate on child YY, then Left Rotate on ZZ.

◇3. Graph Algorithms Comparison

  • Breadth-First Search (BFS): Uses a Queue. Computes unweighted shortest paths in O(V+E)O(V + E).
  • Depth-First Search (DFS): Uses a Stack (or recursion). Detects cycles, topological sorting, and strongly connected components in O(V+E)O(V + E).
  • Dijkstra's Algorithm: Greedy algorithm using a Min-Priority Queue. Computes single-source shortest path for non-negative weights in O((V+E)log⁡V)O((V + E) \log V).
  • Kruskal's Algorithm: Greedy MST algorithm. Sorts edges and applies Disjoint Set Union (DSU / Union-Find) with union-by-rank and path compression in O(Elog⁡E)O(E \log E).
  • Prim's Algorithm: Greedy MST algorithm growing a single tree using a min-heap in O(Elog⁡V)O(E \log V).

◇4. High-Yield Exam Checklist

  • Does QuickSort worst-case occur on already-sorted arrays when picking the first/last element as pivot? YES (O(n2)O(n^2)).
  • In Open Addressing hashing, does quadratic probing eliminate primary clustering? YES, but it causes secondary clustering.
  • Is an AVL tree always a Binary Search Tree? YES (BST property + height-balanced property).
  • Can Dijkstra handle negative edge weights? NO (Must use Bellman-Ford).
  • How many edges are in a spanning tree of a connected graph with VV vertices? Exactly V−1V - 1 edges.

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

What is the time complexity to insert a new element into a binary max heap containing nn elements?

Q2

In an AVL tree, after inserting a node into the left subtree of the right child of node AA, what rotation sequence is required to restore balance?

Q3

Which sorting algorithm is stable and has worst-case time complexity O(nlog⁡n)O(n \log n)?

Q4

In a hash table with load factor α=0.5\alpha = 0.5 using linear probing, what is the primary drawback of linear probing?

Q5

Which graph algorithm will correctly find the Minimum Spanning Tree of a connected weighted graph by sorting all edges in non-decreasing order?

[REV] CCDSALG Comprehensive Finals Reviewer | PROJECT ENGRAM