1.4.2 - Data Structures Flashcards
What is a stack?
A last in first out (LIFO) data structure.
What is are 2 applications of a stack?
The back button on a web browser and used to store information of active subroutines.
What are 5 operations of a stack and what do they do?
.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 does overflow occur in a stack?
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 does underflow occur in a stack?
When you try and pop an item from an empty stack.
What is the stack pointer for this stack [].
-1
What is the stack pointer for this stack [‘Blue’].
0
What is a queue?
A first in first out (FIFO) data structure?
What operations can be performed on a queue and what do they do?
.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()
What is a list?
An abstract data type with a number of items where the same item can occur more than once.
What are 9 operations on a list and what do they do?
.isEmpty() .append(item) .remove(item) .search(item) - Returns Boolean .length() .index(item) - Returns the index of an item .insert(index, item) .pop(index)
What is a graph?
A set of vertices or nodes that are connected by edges or arcs.