everything.study
COMP 2402

Abstract Data Types and Algorithms

0.5 credit · Undergraduate

Introduction to the design and implementation of abstract data types and to complexity analysis of data structures. Topics include: stacks, queues, lists, trees and graphs. Special attention is given to abstraction, interface specification and hierarchical design using an object-oriented programming language.

Study notes

Independent, AI-drafted study guide · Public sources linked below · Added November 5, 2026

Independent guide aligned with public COMP 2402 scope and the Java edition of Pat Morin’s Open Data Structures. The textbook is an openly licensed primary reference; particular advanced tree variants are supplementary rather than guaranteed syllabus topics.

ADT contracts and complexity models

An abstract data type specifies operations and behavior; a data structure supplies a concrete representation. Before comparing implementations, state the operation, input size, and guarantee. Worst-case cost bounds every valid operation sequence of the relevant size; expected cost uses a probability model; amortized cost distributes total work across a sequence without necessarily using randomness. Space matters alongside time. An implementation with fast lookup may pay for spare capacity or additional pointers. Client code should rely on the specified contract rather than undocumented storage details.

References: COMP 2402 ABC — Fall 2024 course outline · Pat Morin — Open Data Structures, Java edition

Array lists, circular queues, and amortization

An array gives constant-time indexed access. Inserting near the front of an array list shifts many elements, making that operation linear. Appending is usually cheap until capacity is exhausted. If capacity doubles when full, occasional copying is expensive but total copying over many appends remains linear, yielding constant amortized append cost. A circular queue stores logical position i at a wrapped physical index. Maintain head and size carefully to distinguish empty and full states. Shrink thresholds should avoid growing and shrinking repeatedly after a small oscillation in size.

References: COMP 2402 ABC — Fall 2024 course outline · Pat Morin — Open Data Structures, Java edition

Linked structures, stacks, and deques

A linked node stores an item plus references connecting nodes. Inserting after a known node can take constant time, but locating the node by index may require a linear traversal. Singly linked lists support efficient head operations; doubly linked lists make movement in both directions easier at the cost of additional references and update obligations. A sentinel can simplify empty and endpoint cases. After insertion or deletion, verify all forward and backward links, size, and head/tail invariants. Linked storage does not automatically make every list operation faster.

References: COMP 2402 ABC — Fall 2024 course outline · Pat Morin — Open Data Structures, Java edition

Hash tables and expected lookup cost

A hash function maps keys into a manageable index range; collisions occur when different keys map to the same bucket or probe region. Chaining stores colliding entries together; open addressing searches alternative slots. The load factor measures entries relative to available capacity. Good expected performance depends on hash behavior, collision handling, and resizing policy. Equality and hashing must agree: keys considered equal need compatible hash codes. Hash-table iteration generally does not provide sorted order. Deleting an open-addressed entry needs care so that it does not break the search path for later entries.

References: COMP 2402 ABC — Fall 2024 course outline · Pat Morin — Open Data Structures, Java edition

Search trees, heaps, and a worked insertion

A binary search tree orders keys so that left descendants are smaller and right descendants are larger under its comparison rule. Search cost follows height; balancing prevents a sorted insertion order from forming a long chain. A binary min-heap instead requires each parent to be no larger than its children. Insert 2 into heap [3, 5, 8, 9]: append it, swap with parent 5, then swap with root 3, giving [2, 3, 8, 9, 5]. This restores heap order in logarithmic time but does not create a sorted array.

References: COMP 2402 ABC — Fall 2024 course outline · Pat Morin — Open Data Structures, Java edition

Graph representations and traversals

An adjacency matrix stores potential edges in a square table and offers direct edge checks using quadratic space. Adjacency lists store existing neighbors and use space proportional to vertices plus edges. Breadth-first search uses a queue and discovers shortest edge-count distances in an unweighted graph. Depth-first search explores one route before returning and can support connectivity and cycle reasoning. Mark vertices at the appropriate point to avoid repeated processing. Traversal costs depend on representation: examining every neighbor list totals O(V + E), whereas scanning a matrix row per vertex can cost O(V squared).

References: COMP 2402 ABC — Fall 2024 course outline · Pat Morin — Open Data Structures, Java edition

Practice & worked answers

Original exercises for this guide.

1. Why is a doubling array’s append constant amortized but not constant worst-case?

Show worked answer

Most appends store one element, but a resize copies the current contents. Across a long sequence, geometrically increasing capacities bound total copying by a constant multiple of the number of appends.

2. Does a min-heap support binary search for an arbitrary key?

Show worked answer

No. Heap order constrains parent-child comparisons, not a global left-to-right ordering. Finding an arbitrary key may require examining many entries.

3. Which traversal finds a path with the fewest edges in an unweighted graph?

Show worked answer

Breadth-first search explores distance layers using a queue. Record a predecessor at first discovery to reconstruct a shortest path from the source.

Public notes & references

Course sources establish the scope above. Reference materials support the explanations; linked lecture notes and books remain with their authors.

2026

Topics

  • Topics Covered
  • and algorithms, including
  • ● Interfaces and Implementation (The Java Collections Framework)
  • ● Sequences: lists, stacks, queues, deques
  • ● Array-based and linked-list-based implementations of sequences
  • ● Unordered sets - hash tables
  • ● Ordered sets - balanced search trees, skiplists
  • ● Priority queues - heaps
  • ● Sorting algorithms
  • ● Graphs
  • ● Applications of data structures
  • ● Performance issues

Readings

  • Textbook: Pat Morin’s Open Data Structures. Free PDF and HTML versions of the book are available at opendatastructures.org. You’ll want the Java version. If you prefer a
  • Pat Morin’s Open Data Structures. Free PDF and HTML versions of the book are available at opendatastructures.org. You’ll want the Java version. If you prefer a

Prerequisites & course information

Precludes additional credit for SYSC 2100 . Prerequisite(s): ( COMP 1006 or COMP 1406 ) with a minimum grade of C- . Lectures three hours a week.

Sources