Lists Stacks and Queues Flashcards

1
Q

Running time of insert of array

A

O(N)

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

Running time of delete of array

A

O(N)

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

Running time of insert/delete at end of array

A

O(1)

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

Running time of trimToSize() for array

A

O(N)

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

What are the 4 applications for Stacks

A
  1. Balancing symbols
  2. Postfix expressions
  3. Infix to Postfix conversion
  4. Method calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the logic to reading a postfix expression using a stack

A

Push numbers until you see an operator, then pop 2 numbers, use the operator against them, and then push the result onto the stack

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

What is the logic to converting postfix to infix using a stack

A
  1. Always push numbers onto output
  2. Only push operators onto the stack, and pop higher priority operators into the output (except open brackets) before pushing onto the stack
  3. For closing brackets, pop all operators until the opening bracket is encountered, and do not push the brackets to the output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What kind of queue can go from end to front

A

Circular Queue

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