S & Q Flashcards

1
Q

Describe stacks

A
  • Stacks are a linear “last in first out” data structure.
  • The most recently added element is always the first element to leave the stack.
  • Principal operations involve push to add elements and pop to remove.
  • Essentially a data set as a stack of plates or books where you can only take the top element off the stack in order to remove things from it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

List common uses for stacks

A
  • Stacks are lists commonly used for storing undo\redo operations and processing languages.
  • Internally, compilers evaluate expressions and syntax parsing implementing a stack.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe queues

A
  • Queues are a linear “first in first out” data structure.
  • The first element to get in the queue will always be the first element to come out of the queue.
  • Principal operations involve enqueue to add elements and dequeue to remove elements.
  • A queue as a line at a grocery store where the person to reach the register first, gets helped first.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List common uses for queues

A
  • Queues are commonly used to maintain first-in-first-out order like HTTP requests to a web service or tasks on an operating system so the CPU can run one job at a time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the general process of sorting a stack

A
  • In order to sort a stack, all items most be popped off. Each item would be stored on a temporary list, then pushed back into the stack in a sorted order.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly