comp 2503 midterm additional flashcards

1
Q

What is the process for drawing an object reference diagram for a linked list?

A
  1. Draw boxes for each node containing data, 2. Draw arrows for references between nodes, 3. Label reference variables (head/tail/current), 4. Show null references with ground symbol or ×
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you verify if parentheses match using a stack?

A
  1. Push opening parentheses onto stack, 2. For each closing parenthesis, pop stack and verify match, 3. Stack should be empty at end, 4. Return false if mismatch or stack not empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the steps to implement Binary Search?

A
  1. Find middle element, 2. Compare with target, 3. If target smaller, search left half, 4. If target larger, search right half, 5. Repeat until found or subarray empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the process for growing an array-based implementation when full?

A
  1. Create new array (typically 2x size), 2. Copy all elements to new array, 3. Update reference to new array, 4. Update capacity variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you maintain references when removing a node from middle of doubly-linked list?

A
  1. Update previous node’s next pointer to skip removed node, 2. Update next node’s previous pointer to skip removed node, 3. Clear removed node’s references, 4. Update size counter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly