Chapter 3 Data Structures Flashcards

(25 cards)

1
Q

What is a data structure?

A

A way of bundling data so it has well-defined rules for access, change, and scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an elementary data type?

A

A simple data value like integers, reals, characters, or booleans.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Difference between arrays and lists?

A

Arrays are fixed-type, fixed-size; lists can be variable-type and dynamic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a record?

A

A fixed collection of variables (attributes) under a common name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why arrays are O(1) access?

A

Because element positions can be computed directly using memory offset.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a pointer?

A

A variable that stores the memory address of another variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why arrays can’t store different types?

A

Because they use fixed-size memory blocks for each entry.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a linked list?

A

A data structure of nodes (triplets: previous, key, next) linked together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the head of a list?

A

The first node (triplet) in a linked list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a doubly linked list?

A

A list where each node has pointers to both the previous and next nodes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Accessing the i-th item in a list?

A

O(n) since you must traverse from the head to the i-th node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Adding an item to the end of a list?

A

O(1) if you use the tail pointer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a queue?

A

A FIFO (first-in-first-out) data structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a stack?

A

A FILO (first-in-last-out) data structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a rooted binary tree?

A

A tree with a starting root node where each node has ≤ 2 children.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Structure of a binary tree node?

A

(left, key, right) triplet.

17
Q

What is a graph?

A

A set of vertices and edges representing relationships.

18
Q

What is an adjacency matrix?

A

A 2D array showing vertex connections in a graph.

19
Q

What is an adjacency list?

A

An array of lists storing only adjacent vertices.

20
Q

What is a hash function?

A

A function that maps data (keys) to integer indexes.

21
Q

What is a hash table?

A

A structure using a hash function to store and access data in O(1) time.

22
Q

What is a hash collision?

A

When two keys map to the same hash table index.

23
Q

How to resolve hash collisions?

A

By chaining (linked lists) or open addressing (probing).

24
Q

What is chaining?

A

Storing colliding entries in a linked list at each hash table slot.

25
What is open addressing?
Finding another free slot via probing when a collision occurs.