1.4.2 - Data Structures Flashcards

1
Q

What is a stack?

A

A last in first out (LIFO) data structure.

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

What is are 2 applications of a stack?

A

The back button on a web browser and used to store information of active subroutines.

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

What are 5 operations of a stack and what do they do?

A

.push(item) - Adds a new item to the top of a stack.
.pop() - Removes and returns the top item from the stack.
.peek() - Returns the top item from the stack but does not remove it.
.isEmpty() - Returns a boolean value of whether the stack is empty.
.isFull() - Returns a boolean value of where the stack is full.

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

How does overflow occur in a stack?

A

A stack will always have a maximum size because memory cannot grow indefinitely therefore, if you try to push an item to a full stack overflow will occur.

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

How does underflow occur in a stack?

A

When you try and pop an item from an empty stack.

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

What is the stack pointer for this stack [].

A

-1

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

What is the stack pointer for this stack [‘Blue’].

A

0

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

What is a queue?

A

A first in first out (FIFO) data structure?

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

What operations can be performed on a queue and what do they do?

A

.enQueue(item) - Add a new item to the end of the queue.
.deQueue() - Remove the front item from the queue and return it.
.isEmpty()
.isFull()

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

What is a list?

A

An abstract data type with a number of items where the same item can occur more than once.

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

What are 9 operations on a list and what do they do?

A
.isEmpty()
.append(item)
.remove(item)
.search(item) - Returns Boolean
.length()
.index(item) - Returns the index of an item
.insert(index, item)
.pop(index)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a graph?

A

A set of vertices or nodes that are connected by edges or arcs.

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