SLR04 - Data Structure Flashcards

(50 cards)

1
Q

What is a data structure?

A

A way of organising and storing data in a computer so it can be accessed and modified efficiently.

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

What is an array?

A

A static data structure that stores data contiguously in memory and holds one data type.

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

Difference between array and list?

A

Arrays are static and store one data type; lists are dynamic and can store multiple data types.

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

Difference between tuple and list?

A

Tuple is immutable and fixed-size. list is mutable and changeable.

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

Why are arrays called static?

A

Because their size is fixed at the time of creation and cannot be changed later.

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

What is a binary file?

A

A non-text file storing data in binary form, often with mixed data types.

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

How is a real number stored differently in a binary file?

A

Stored in compact binary form instead of text, using fewer bytes.

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

What is a static data structure?

A

A structure with a fixed size where memory allocation doesn’t change during program runtime.

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

One benefit and drawback of static structures?

A

Benefit: Easier to program. Drawback: Inefficient use of memory.

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

What is a dynamic data structure?

A

A structure that can grow and shrink during runtime.

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

One benefit and drawback of dynamic structures?

A

Benefit: Efficient memory use. Drawback: Harder to program.

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

What is a stack?

A

A LIFO (Last-In-First-Out) data structure.

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

What operations are used on a stack?

A

Push, Pop, Peek.

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

What is stack overflow and underflow?

A

Overflow: Pushing to full stack. Underflow: Popping from empty stack.

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

What does the stack pointer do?

A

Points to the top item of the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
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
17
Q

What operations are used on a queue?

A

Enqueue, Dequeue, Peek.

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

What is stack overflow and underflow?

A

Overflow: Pushing to full stack. Underflow: Popping from empty stack.

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

What does the stack pointer do?

A

Points to the top item of the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
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
21
Q

What operations are used on a queue?

A

Enqueue, Dequeue, Peek.

22
Q

What is queue overflow and underflow?

A

Overflow: Enqueue to full queue. Underflow: Dequeue from empty queue.

23
Q

What are front and back pointers in a queue?

A

Front: Points to the item to dequeue. Back: Points to where to enqueue.

24
Q

What problem does a circular queue solve?

A

Prevents unused space when back reaches the end of the array by looping around.

25
Steps to push to a stack?
Check overflow → Increment pointer → Insert item.
26
Steps to pop from a stack?
Check underflow → Output item → Decrement pointer.
27
Steps to enqueue to a queue?
Check overflow → Increment back pointer → Insert item.
28
Steps to dequeue from a queue?
Check underflow → Output item → Increment front pointer.
29
What is a graph?
A structure with nodes and edges. Edges may be directed or undirected.
30
What is a directed vs undirected graph?
Directed: edges point one way. Undirected: edges go both ways.
31
What is a weighted graph?
A graph where each edge has a value (e.g., distance, cost).
32
What is an adjacency matrix?
2D array representing graph edges between nodes.
33
What is an adjacency list?
Dictionary mapping nodes to a list of connected nodes.
34
When is adjacency list better than matrix?
When the graph is sparse (fewer connections).
35
What is a tree?
A connected, undirected graph with no cycles.
36
What is a rooted tree?
A tree with one root node at the top.
37
What is a binary tree?
A tree where each node has up to 2 children (left, right).
38
How are binary trees stored?
As arrays or dictionaries.
39
What is a hash table?
A data structure that maps keys to values using a hash function.
40
What is a hash function?
A function that calculates the index to store or find data.
41
What is a collision in hashing?
When two keys hash to the same index.
42
What is open addressing?
Finding next empty space when collision occurs.
43
What is linear probing?
Searching sequentially for next available slot.
44
What is rehashing?
Finding a new position for a key when collision occurs.
45
Steps to add to a hash table?
Hash → If empty, insert → Else check overflow table → Insert when space found.
46
Steps to delete from a hash table?
Hash → If match, delete → Else search overflow table → Delete when found.
47
Steps to search a hash table?
Hash → Check value → If not match, check overflow table → Return value or 'Not Found'.
48
What is a dictionary?
An abstract data structure storing key-value pairs.
49
How is a dictionary accessed?
Using the key to retrieve the associated value.
50
What is a vector?
A series of numbers representing data like position, velocity, or force.