Operations on Data Structures Flashcards

(13 cards)

1
Q

How do you create a 1D array in OCR pseudocode?

A

Use arrayName ← [ ] or declare with initial size, e.g., arrayName ← new array[5].

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

How do you add an item to a 2D array in pseudocode?

A

Use two indices, e.g., array[x][y] ← value.

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

How do you remove an item from a 3D array?

A

Set the element at the specific 3D index to null or default, e.g., array[x][y][z] ← 0.

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

How do you add a node to a linked list?

A

Create a new node and adjust pointers to insert it at the desired position.

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

How do you remove a node from a linked list?

A

Redirect the pointer of the previous node to the node after the one being removed.

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

How do you add an element to a stack?

A

Push the item to the top using stack.push(value) or add at top ← top + 1.

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

How do you remove an element from a stack?

A

Pop the top element and update the top pointer.

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

How do you add an item to a queue?

A

Insert the item at the rear and update the rear pointer.

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

How do you remove an item from a queue?

A

Remove the item from the front and update the front pointer.

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

How is data added to a binary search tree (BST)?

A

Compare to the root; go left if smaller, right if larger; insert in correct null position.

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

How is data removed from a binary search tree (BST)?

A

Find the node; if it has: No child: remove directly, One child: link parent to child, Two children: replace with inorder successor/predecessor.

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

How is data added to a hash table?

A

Use a hash function to compute the index and insert at that position or handle collision.

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

What does traversing a data structure mean?

A

Visiting each element in a specific order to read or modify its data.

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