Back to all Computer Science topics
Topic 8.1Computer Science HL30 flashcards

Fundamentals of ADTs

Practice Flashcards

Flip cards to reveal answers
Card 1 of 308.1.1
8.1.1
Question

What does an abstract data type define?

Click to reveal answer

Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.

All Flashcards in Topic 8.1

Below are all 30 flashcards for this topic. Sign up free to track your progress and get personalized review schedules.

8.1.15 cards

Card 1definition
Question

What does an abstract data type define?

Answer

The **operations** available and what they mean — not how the data is stored.

Card 2concept
Question

ADT or data structure: a stack?

Answer

**ADT.** It promises push, pop, peek and last-in-first-out order. An array or a linked list is how you build one.

Card 3concept
Question

Why hide an ADT's implementation?

Answer

So it can be **replaced** without changing any calling code, because callers only ever depended on the operations.

Card 4definition
Question

Which ADT enforces uniqueness?

Answer

A **set** — duplicates cannot be stored, so the structure guarantees it rather than the programmer remembering to check.

Card 5example
Question

How should an ADT choice be justified in an exam?

Answer

By the operation the program performs **most**, with its complexity — and what the alternative would cost.

8.1.25 cards

Card 6definition
Question

What does each node in a singly linked list hold?

Answer

A **value** and a **reference to the next node**. Nothing else, and no node needs to sit beside another in memory.

Card 7concept
Question

Why is reaching the nth element of a linked list O(n)?

Answer

There is no calculation that locates a node — you must start at the head and **follow every reference** in turn.

Card 8comparison
Question

Singly, doubly, circular — what is the difference?

Answer

**Singly** points forwards only. **Doubly** points both ways, at the cost of a second reference per node. **Circular** links the last node back to the first, so there is no null end.

Card 9concept
Question

What is the linked-list trade-off?

Answer

It gives up **direct access** (O(n) to reach position n) and gains **cheap insertion and deletion** (O(1) once in position), plus a size that grows and shrinks.

Card 10example
Question

Why can an array beat a linked list even when complexity says otherwise?

Answer

Array elements are **contiguous**, so reading one pulls its neighbours into cache. Linked-list nodes are scattered, so each hop risks a cache miss.

8.1.35 cards

Card 11definition
Question

What two things define a linked list?

Answer

A **Node** holding a value and a reference to the next, and a **head** reference pointing at the first node.

Card 12process
Question

In what order are the two references assigned when inserting?

Answer

**Point the new node forwards first** (new.next ← prev.next), then repoint the previous node (prev.next ← new). The other order overwrites the only reference to the rest of the list.

Card 13process
Question

How is a node deleted from a singly linked list?

Answer

By **routing around it**: prev.next ← target.next. Nothing is erased — the node simply becomes unreachable.

Card 14concept
Question

Why is deleting the head a special case?

Answer

There is no previous node to reroute, so the head itself moves: head = head.next.

Card 15process
Question

How does a traversal of a circular list stop?

Answer

When current returns to the **head**. There is no None to test for.

8.1.45 cards

Card 16definition
Question

What is the binary search tree ordering rule?

Answer

For **every** node, all values in its left subtree are smaller and all in its right subtree are larger — every descendant, not just the children.

Card 17concept
Question

Why is a BST search fast?

Answer

Each comparison says which side the value must be on, so an **entire subtree** is discarded without being examined. About log₂ n comparisons when balanced.

Card 18process
Question

What does an in-order traversal give you?

Answer

Every value in **ascending order** — left subtree, node, right subtree — with no sorting step.

Card 19concept
Question

What does sorted input do to a BST?

Answer

Every value goes the same direction, so the tree **degenerates into a line**: height n, search O(n), exactly like a linked list.

Card 20process
Question

How is a node with two children deleted?

Answer

It is replaced by its **in-order successor** — the smallest value in its right subtree — which preserves the ordering rule.

8.1.55 cards

Card 21definition
Question

What two guarantees does a set make?

Answer

**No duplicates** and **no order** — both enforced by the structure rather than by the programmer.

Card 22definition
Question

Union, intersection, difference — what are they?

Answer

**Union** everything in either · **intersection** only what is in both · **difference** in the first and not the second.

Card 23concept
Question

Is a − b the same as b − a?

Answer

**No.** With a = {1,2,3} and b = {3,4}: a − b = {1,2} but b − a = {4}. Difference is the one operation whose order matters.

Card 24concept
Question

Why is set membership O(1) on average?

Answer

The value itself computes where it would be stored, so nothing is searched for. A list must compare against every element — O(n).

Card 25example
Question

When is a set the wrong choice?

Answer

When the program needs **position or order** — a set has neither, and no index to ask with.

8.1.65 cards

Card 26process
Question

How does a hash table locate a value?

Answer

It runs the key through a **hash function**, takes the result **modulo the table size**, and goes straight to that bucket. The address is computed, not searched for.

Card 27definition
Question

What three properties must a hash function have?

Answer

**Deterministic** (same key, same bucket, always), **fast** (it runs on every operation) and **uniform** (keys spread evenly).

Card 28concept
Question

Why are collisions inevitable?

Answer

There are more possible keys than buckets, so two keys must eventually map to the same one. It is a counting argument, not a defect.

Card 29comparison
Question

Chaining or open addressing — what is the difference?

Answer

**Chaining** stores colliding keys in a list inside the bucket. **Open addressing** puts them in the next free bucket, so the table can never hold more items than buckets.

Card 30concept
Question

What is a hash table's complexity?

Answer

**O(1) on average, O(n) in the worst case** — the worst case being a hash function that clusters every key into one bucket.

Want smart review reminders?

Sign up free to track your progress. Our spaced repetition algorithm will tell you exactly which cards to review and when.

Start Free