Lecture 1 - ADTs Flashcards

1
Q

What methodology does a stack follow?

A

Last In First Out

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

What are the basic operations of a stack?

A
  • create
  • isEmpty
  • push
  • pop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can a stack be implemented?

A
  • array
  • linked list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the time complexity of stack operations when it is implemented with an array ?

A

O(1)

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

What is the time complexity of stack operations when it is implemented with a linked list ?

A

O(1)

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

What methodology does a queue follow?

A

First In First Out

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

What are the basic operations of a queue?

A
  • create
  • isEmpty
  • insert
  • delete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the time complexity of queue operations when it is implemented with an array ?

A

O(1) when using a circular queue

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

What is the time complexity of queue operations when it is implemented with a linked list ?

A

O(1) when we have a head and tail

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

What is a priority queue compared to a queue?

A

The order of removal depends on priority rather than time of addition.

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

What are the operations on a priority queue?

A

same as a queue

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

How can a priority queue be implemented?

A
  • linked list (ordered or unordered)
  • heap
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the time complexity for create and isEmpty for all implementations?

A

O(1)

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

What is the time complexity of insert and delete for an LL implementation?

A

Ordered: O(n) for delete and O(1) for insert

Unordered : O(1) for insert O(n) for delete

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

What is the time complexity of insert and delete for a heap implementation?

A

O(logn)

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