← profjeff.org  ·  COMP 220 — Data Structures & Algorithms

COMP 220 — Code Downloads

All homework and lab starter code, plus practice problem starter/solution code, one zip per item. Click a unit to expand it. Download a zip, unzip it, and open it in the IDE of your choice (VS Code, Programiz, etc.). No account or login is needed.

Week 1  — Units 1 & 2, HW 1
Unit 1  — HW 1

📝 HW 1 - Analyzing My Sort

Unit 2  — Practice Problems, Lab

🔧 Practice problems

🧪 Lab 02: Guess My Number

Week 2  — Units 3 & 4
Unit 3  — Practice Problems, Lab

🔧 Practice problems

🧪 Lab 03: Write a mySortThree() function

Unit 4  — empty
Week 3  — Units 5 & 6, HW 2
Unit 5  — Practice Problems, Lab, HW 2

📝 HW 2 - The Lost Amulet of King Obfuscate

🔧 Practice problems

🧪 Lab 05: Recursive "Guess My Number" algorithm

Unit 6  — Lab

🧪 Lab 06: Recursive Differences

Week 4  — Units 7 & 8
Unit 7  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Finish printStack() method in class stackArray
    StarterSolution
  • Practice 2: Practice 2: Finish resize() method in class stackArray
    StarterSolution
  • Practice 3: Practice 3: Finish printStack() method in class stackLinkedList
    StarterSolution

🧪 Lab 07: Reversing an array using a Stack

Unit 8  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Implement printQueueOldToNew()
    StarterSolution
  • Practice 2: Practice 2: Add nextOlder pointer to enqueue() and dequeue()
    StarterSolution

🧪 Lab 08: Implement a QueueViaStack class by using 2 Stacks (optional)

Week 5  — Units 9 & 10, HW 3
Unit 9  — Lab, HW 3

📝 HW 3 - Priority Queue Linked List

🧪 Lab 09: Heap Array Introduction

Unit 10  — Lab

🧪 Lab 10: Heap Array Recursive Test

Week 6  — Units 11 & 12
Unit 11  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Observe printGeeks() function Legend
    Starter
  • Practice 2: Practice 2: Finish depth-First printTree() function
    StarterSolution
  • Practice 3: Practice 3: Implement a “PRE-Order” traversal in printTree()
    StarterSolution
  • Practice 4: Practice 4: Insert - always left, (or always Right) in printTree()
    StarterSolution

🧪 Lab 11: Is Valid Binary Search Tree

Unit 12  — Practice Problems

🔧 Practice problems

  • Practice 3: Practice 3: Implement a sorted insert() function for a BST
    StarterSolution
  • Practice 5: Practice 5: Implement a find_brute_force() function for a BST
    StarterSolution
  • Practice 6: Practice 6: Implement a find_optimal() function for a BST
    StarterSolution
  • Practice 7: Practice 7: Implement a get_min_node() function for a BST
    StarterSolution
  • Practice 8: Practice 8: Implement a get_size() function for a BST
    StarterSolution
Week 7  — Units 13 & 14, HW 4
Unit 13  — Practice Problems, HW 4

📝 HW 4 - Due End of Semester (long term assignment)

🔧 Practice problems

  • Practice 1: Practice 1: Implement a delete_node() function for a BST
    StarterSolution
  • Practice 2: Practice 2: Finish Implementation of update_maxDepth() function for a BST
    StarterSolution
Unit 14  — Lab

🧪 Lab 14: Choose your own Adventure: Trees or Analysis

Week 8  — Units 15 & 16
Unit 15  — no lab
Unit 16  — Midterm
Week 9  — Units 17 & 18, HW 5
Unit 17  — Practice Problems, Lab, HW 5

📝 HW 5 - Symbol Table via Hash Tables with Separate Chaining

🔧 Practice problems

  • Practice 1: Practice 1: Double Linked List, Insert Key:Value Pair
    StarterSolution
  • Practice 2: Practice 2: Double Linked List, Delete Key:Value Pair
    StarterSolution
  • Practice 3: Practice 3: Double Linked List, Get Value from Key
    StarterSolution
  • Practice 4: Practice 4: Binary Search Array: Find Key Position
    Starter

🧪 Lab 17: Implement the SymbolTable containsKey( ) method

Unit 18  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Hash Table, Simple hash( key, M ) function
    StarterSolution
  • Practice 2: Practice 2: Hash Table, Insert Keys until Collision
    StarterSolution
  • Practice 3: Practice 3: Hash Table, insert with Separate Chaining, with val = count
    StarterSolution
  • Practice 4: Practice 4: Hash Table, insert with Separate Chaining Copy
    StarterSolution

🧪 Lab 18: Implementing the "DJB" hash

Week 10  — Units 19 & 20
Unit 19  — Practice Problems, Lab

🔧 Practice problems

  • Practice 0: Practice 0: Hash Table,Incorporate folding in hash( key, M )
    StarterSolution
  • Practice 1: Practice 1: Hash Table, Linear Probing (Open Addressing)
    StarterSolution
  • Practice 2: Practice 2: Hash Table, Compute a Linear probing slope (Open Addressing)
    StarterSolution
  • Practice 3: Practice 3: Hash Table, Quadratic Probing & M=pow(2, r) (Open Addressing)
    StarterSolution

🧪 Lab 19: Hash Table Collision via Random Probing

Unit 20  — Lab

🧪 Lab 20: Delete Every Kth Node (optional)

Week 11  — Units 21 & 22, HW 6
Unit 21  — Practice Problems, Lab, HW 6

📝 HW 6 - Connected Components (Undirected Graphs)

🔧 Practice problems

🧪 Lab 21: Graphs (undirected) Print "Friends of Friends" for a Graph Vertex

Unit 22  — Practice Problems, Lab

🔧 Practice problems

  • Practice 2: Practice 2: Graphs, Finish Paths::dfs() function
    StarterSolution

🧪 Lab 22: Print all Reachable Vertices in a Graph using Paths class

Week 12  — Units 23 & 24
Unit 23  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Graphs, Finding Paths via Breadth-First-Search (BFS)
    StarterSolution
  • Practice 2: Practice 2: Graphs, Paths, adding distance to Path::bfs()
    StarterSolution
  • Practice 3: Practice 3: Graphs, Is Bipartite? using Bipartite :: dfs( )
    StarterSolution
  • Practice 4: Practice 4: Graphs, Finding Cycles using CycleFinder:: dfs( )
    StarterSolution

🧪 Lab 23: Graphs, Paths - Find Shortest Distance using BFS

Unit 24  — Practice Problems

🔧 Practice problems

  • Practice 1: Practice 1: Union-Find, Implement getGroup()
    StarterSolution
  • Practice 2: Practice 2: Union-Find, Implement doCompress()
    StarterSolution
  • Practice 3: Practice 3: Union-Find, Percolate (Monte Carlo Simulation)
    StarterSolution
Week 13  — Units 25 & 26, HW 7
Unit 25  — Practice Problems, HW 7

📝 HW 7 - Crazy Taxi Town

🔧 Practice problems

  • Practice 2: Practice 2: DiGraphs, Modify Graph to utilize Graph::isDirected
    StarterSolution
  • Practice 4: Practice 4: DiGraphs, Finish DEPTHFIRSTORDER Class (topo sort)
    StarterSolution
  • Practice 5: Practice 5: DiGraphs, Finish DirectedCycle :: dfs( vid )
    StarterSolution
Unit 26  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: DiGraphs, Reversing a Graph
    StarterSolution
  • Practice 2: Practice 2: DiGraphs, Finish implementation of SCC class
    StarterSolution

🧪 Lab 26: Finding Strongly-connected components of size 1

Week 14  — Units 27 & 28
Unit 27  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Graphs, MST, Finish Edge Weighted Class
    StarterSolution
  • Practice 2: Practice 2: Graphs, MST, Finish Kruskal MST Constructor
    StarterSolution

🧪 Lab 27: Min Spanning trees : HollerTown vs Pretty-Good Electric

Unit 28  — empty
Week 15  — Units 29 & 30, HW 8
Unit 29  — HW 8

📝 HW 8 - Maximum Flow (DIRECTED Graphs)

Unit 30  — empty
Week 16  — Units 31 & 32
Unit 31  — Practice Problems, Lab

🔧 Practice problems

  • Practice 1: Practice 1: Brute Force String Search
    StarterSolution
  • Practice 2: Practice 2: Brute Force String Search (Backing Up approach)
    Solution
  • Practice 3: Practice 3: State Machines Intro
    StarterSolution
  • Practice 4: Practice 4: Knuth-Morris-Pratt String Search, printDF() method
    StarterSolution
  • Practice 5: Practice 5: Boyer-Moore String Search
    StarterSolution

🧪 Lab 31: Knuth-Morris-Pratt DFA Matrices (Optional)

Unit 32  — empty
Week 17  — Unit 33
Unit 33  — empty