2.3.2 Algorithms for Main Data Structures Flashcards

1
Q

Are stacks FIFO or FILO?

A

FILO

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

Which function adds an item to a stack?

A

Push

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

Which functions removes an element from a stack?

A

Pop

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

Which function adds an element to a queue?

A

Enqueue

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

Which function removes an element from a queue?

A

Dequeue

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

What is the purpose of a back pointer in a queue?

A

Holds the location of the next available space

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

Which function returns an item at the front of the queue without removing it?

A

Peek

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

What is the purpose of the front pointer in a queue?

A

Points to space containing the first item

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

What value is the top pointer initiliased to in a stack?

A

-1

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

Give pseudocode for the function adding new elements to a stack.

A

push(element)
top = top + 1
A[top] = element

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

Give pseudocode for the function adding new elements to a queue.

A

enqueue(element):
A[back] = element
back = back + 1

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

Which function returns the item at the top of a stack without removing it?

A

Peek

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