1.4.2 - Data Structures Flashcards

(55 cards)

1
Q

What is an array?

A

An ordered, finite set of elements of a single type.

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

How is a 1D array typically indexed?

A

Zero-indexed (first element is at position 0).

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

What is a 2D array?

A

An array that can be visualized as a table with rows and columns.

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

How do you access an element in a 2D array?

A

Specify [row, column] or [y, x] depending on convention.

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

What is a 3D array?

A

An array that can be visualized as multiple 2D arrays (like a multi-page spreadsheet).

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

How do you access an element in a 3D array?

A

Specify [array_number, row, column] or [z, y, x].

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

What is a record?

A

A data structure made up of fields, commonly representing a row in a database.

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

How are records declared?

A

Using a record structure that defines each field’s data type.

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

How do you access a field in a record?

A

Using recordName.fieldName syntax.

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

What is a list?

A

An ordered collection of items that can contain elements of different data types.

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

How do lists differ from arrays?

A

Lists are stored non-contiguously in memory and can hold mixed data types.

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

What does the isEmpty() function do for a list?

A

Checks if the list is empty.

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

What does the append(value) function do?

A

Adds a new value to the end of the list.

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

What does the remove(value) function do?

A

Removes the first occurrence of the specified value.

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

What does the search(value) function do?

A

Searches for a value in the list and returns a boolean.

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

What does the length() function do?

A

Returns the number of items in the list.

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

What does the index(value) function do?

A

Returns the position of the first occurrence of the value.

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

What does the insert(position, value) function do?

A

Inserts a value at the specified position in the list.

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

What does the pop() function do?

A

Removes and returns the last value in the list.

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

What does the pop(position) function do?

A

Removes and returns the value at the specified position.

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

What is a tuple?

A

An ordered, immutable set of values of any type.

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

How are tuples different from lists?

A

Tuples are immutable (cannot be changed after creation).

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

How are tuples initialized?

A

Using regular parentheses () instead of square brackets [].

24
Q

What is a linked list?

A

A dynamic data structure where each node contains data and a pointer to the next node.

25
What are the components of a linked list node?
Data field and pointer/reference field.
26
What pointers are maintained in a linked list?
Start pointer (first node) and NextFree pointer (next available space).
27
How do you traverse a linked list?
Start at the Start pointer and follow pointers until reaching a null pointer.
28
How are values added to a linked list?
Update pointers to insert the new node in the sequence.
29
How are values removed from a linked list?
Update pointers to bypass the node to be removed.
30
What is a graph?
A set of vertices/nodes connected by edges/arcs.
31
What is a directed graph?
Edges can only be traversed in one direction.
32
What is an undirected graph?
Edges can be traversed in both directions.
33
What is a weighted graph?
Edges have associated costs/weights.
34
What is an adjacency matrix?
A 2D array representing which vertices are connected.
35
What is an adjacency list?
A collection of lists showing each vertex's connections.
36
What is a stack?
A LIFO (Last In First Out) data structure.
37
What are common stack operations?
push(value), pop(), peek(), isEmpty(), isFull(), size()
38
What does push(value) do?
Adds a value to the top of the stack.
39
What does pop() do?
Removes and returns the top value from the stack.
40
What does peek() do?
Returns the top value without removing it.
41
What is a queue?
A FIFO (First In First Out) data structure.
42
What are common queue operations?
enQueue(value), deQueue(), isEmpty(), isFull()
43
What does enQueue(value) do?
Adds a value to the end of the queue.
44
What does deQueue() do?
Removes and returns the value from the front of the queue.
45
What is a linear queue?
A queue implemented as an array with front and rear pointers.
46
What is a circular queue?
A queue where the rear pointer can wrap around to the front when full.
47
What is a tree?
A connected graph with a root node and hierarchical structure.
48
What is a binary tree?
A tree where each node has at most two children.
49
What is pre-order traversal?
Root node, left subtree, right subtree.
50
What is in-order traversal?
Left subtree, root node, right subtree.
51
What is post-order traversal?
Left subtree, right subtree, root node.
52
What is a hash table?
An array coupled with a hash function that maps keys to indices.
53
What is a hash function?
A function that takes a key and returns an index in the hash table.
54
What is a collision in hashing?
When two different keys produce the same hash value.
55
What is collision resolution?
Handling collisions, often by placing the item in the next available location.