ADT Stacks and Queues (Module 3) Flashcards

1
Q

What is a single expected way to traverse elements in a data structure?

A

linear

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

What is a structure that can hold elements and give us a way to get them back?

A

worklists

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

What is a container where elements are added and removed only at the end?

A

stack

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

Stacks are characterized by which two operations?

A

push() and pop()

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

Which operation adds a new element to the stack?

A

push()

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

Which operation removes an element from the stack?

A

pop()

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

The insertion and retrieval of elements in a stack follows the “___ In, _____ Out” discipline

A

Last In, First Out

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

What is an operator that returns a reference to an element at the top of the stack but doesn’t remove it from the stack?

A

peek()

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

Which operator returns “True” if the stack is empty, and “False” in other cases?

A

isEmpty()

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

What occurs when attempting to insert a new element into a stack that’s already reached its maximum size limit?

A

stack overflow

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

What occurs when attempting to delete or retrieve an element from a stack that’s empty

A

stack underflow

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

What is thee asymptotic complexity for pop() and push()?

A

O(1)

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

What is a container where the elements are added at one end and removed at another end?

A

Queue

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

Queues are characterized by which two operators?

A

enqueue() and dequeue()

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

Which operator inserts a new element into the queue?

A

enqueue()

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

Which operator removes the first element of the queue?

17
Q

Queues follow the “_____ In, ______ Out” discipline.

A

First In, First Out (FIFO)

18
Q

Which copy creates a new object but doesn’t create copies of nested objects?

A

shadow copy

19
Q

Which copy creates a completely independent copy of the original object, including copies of all the nested objects?