SDD - Data Structures Flashcards
Explain what a 2-D array is…
A 2-D array is an array of arrays, it stores data in a grid form, with columns and rows to identify each item in the 2-D array. All the data in the 2-D array is of the same data type.
Name and describe the two types of errors in a Stack…
Stack Overflow - When you try to ‘push’ an item on to an already full Stack.
Stack Underflow - When you try to ‘pop’ an item from an empty Stack.
Explain what a Stack is…
A Stack operates under the structure LIFO (Last in first out), which means it always deletes and adds items to the very top of the Stack. The data stored in a Stack is all of the same data type. A variable is kept which holds the value of the index of the top item of the Stack.
Explain what a Queue is…
A Queue operates under the structure FIFIO (First in first out), so it deletes items from the front and adds to the back. The data is all of the same data type. Two variables are kept which store the index of the front and back of the queue.
Describe what happens to the front and back variables for a queue as items are deleted and added…
The front of the queue increases by one when you delete an item (So that it shows the next item in the queue) and when items are added the back increases by one (Because a new item has joined the back of the queue).
What happens when the items in a queue reach the very end of the queue?
If the is space at the very front of the Queue, the Queue becomes a circular Queue, and the back variable goes the the first index. The Queue can then stay like this or if the programmer want, they can shuffle the Queue back into place.