Data Structures and Manipulation Flashcards

1
Q

State the term used to describe data structures where the size is fixed when created.

A

Static

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

State an example of a static data structure.

A

Array

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

What are the advantages of using static data structures?

A
  • Compiler can allocate space in memory during compilation
  • Easy to program
  • Easy to check for overflow
  • Allows random access
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the disadvantages of using static data structures?

A
  • Program has to estimate maximum space needed

- Space can be wasted via over-estimation

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

What are the advantages of using dynamic data structures?

A
  • Only uses the space needed at any time
  • Makes efficient use of memory
  • Storage no longer required can be returned to the system for other use
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the disadvantages of using dynamic data structures?

A
  • Difficult to program
  • Can be slow to implement searches on data
  • A linked list only allows serial access (time consuming for long lists)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Under what condition is a queue empty?

A

When front and next pointers point to the same location.

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

Write an algorithm to remove one data item from a queue.

A
  1. Check to see if the queue is not empty.
  2. If empty, report error and stop.
  3. Otherwise read the data pointed to by front pointer
  4. Increment front pointers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write an algorithm to merge two sorted files.

A
  1. Open existing files
  2. Create new file
  3. Use points to identify records for comparison
  4. Compare records indicated to by pointers
  5. Copy earlier/smaller value record to new file
  6. Increment point from copied record
  7. Repeat until reach the end of one file
  8. Copy remaining records to new file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the main advantage to binary search?

A
  • (usually) faster than serial because fewer items are checked/more efficient for large files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the main disadvantage for binary search?

A
  • items must be in an order to allow appropriate items to be discarded
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

State two features of files that can be merged.

A
  • records have a common key
  • files each have records sorted into the same order
  • same data type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe a queue data structure.

A
  • first in, first out/FIFO/data items are added at one end & removed from the other
  • two pointers are required
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

State uses of a queue in a computer system.

A
  • spool queue/jobs waiting for printer
  • job queue in batch processing system
  • Handling of jobs in a round robin system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What validation must be done before adding data to a queue?

A

Check if full, if full report error and stop

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

What validation must be done before removing data from a queue?

A

Check if empty, if empty report error and stop

17
Q

Write an algorithm to add a data item to an existing binary tree.

A

start at root
repeat
compare new data with current data
if new data

18
Q

What data structure is FIFO?

A

Queue

19
Q

What data structure is FILO?

A

Stack

20
Q

State features of a quick sort that is not used in insertion sort.

A
  • set of numbers broken into multiple sets

- uses pivots

21
Q

List the steps needed to pop a data item from a stack.

A
  • if stack is empty…
  • …report error and stop
  • output data(stack_pointer)
  • decrement stack_pointer