F453 Data Structures - Stacks and Queues

Description

Flashcards on F453 Data Structures - Stacks and Queues, created by harvs899 on 02/05/2014.
harvs899
Flashcards by harvs899, updated more than 1 year ago
harvs899
Created by harvs899 over 10 years ago
465
15

Resource summary

Question Answer
What is a static data structure? A data structure which can not change size at runtime.
What is a dynamic data structure? A data structure which can change size at runtime in order to accommodate stored data.
What is a LIFO data structure? The last item pushed in is the first to be popped out (Last In First Out). Imagine a stack of plates.
What is a FIFO data structure? The first item to be pushed in is the first item to be popped out (First In First Out). Imagine a queue in a shop.
How is the location of the top of a stack kept track of? The stack pointer, this points to the top most item in the stack - not the free space above the stack!
In a queue how many pointers are there and what are they? There are two pointers, the front and back. Which obviously point to the front and back items of the queue.
Are items actually deleted from the stack? If not what happens instead? The stack pointer is simply decremented, leaving the 'deleted' item to be overwritten the next time something is pushed on to the stack.
If you add an item to a stack you _____ the item on to it. Push.
If you remove an item from a stack you ____ an item off of it. Pop.
What happens if the stack gets too large? Stack overflow exception.
What is a stack underflow? This occurs when you try to remove an item from an empty stack.
In a queue what does it mean when the front and back pointers are in the same location? The queue is empty.
What is the algorithm for pushing on to a stack? Check to see if the stack is full, if it is report an error and stop. If it is not full, increment the stack pointer, add the item to the top of the stack then stop.
What is the algorithm for popping off of a stack? Check to see if the stack is empty, if it is report an error and stop. If it is not empty, copy the item off the stack then decrement the stack pointer.
Where is an item removed from a queue? The front.
Where is an item added to a queue? The back.
What are the advantages of a static data structure? They are easier to program, easy to check for overflow, compiler allocate space at compile time and an array allows random access.
What are the disadvantages of a static data structure? The programmer must estimate the maximum amount of space required, it can also be wasteful of memory.
What are the advantages of a dynamic data structure? Only uses the space required, makes efficient use of memory and storage no longer required can be returned to the system for other uses.
What are the disadvantages of a dynamic structure? Difficult to program, can be slow to implement searches and a linked list only allows serial access.
What is the algorithm to enqueue an item? Check to see if the queue is full, if it is report an error and stop. If it is not full then allocate memory to a new node and adjust the rear pointer to accommodate the new item.
What is the algorithm to dequeue an item? Check to see if the queue is empty, if it is report and error and stop. If it is not empty mark the memory that the item used as free and adjust the front pointer to locate the previous item.
Show full summary Hide full summary

Similar

A level Computing Quiz
Zacchaeus Snape
Computing Hardware - CPU and Memory
ollietablet123
All AS Maths Equations/Calculations and Questions
natashaaaa
Using GoConqr to teach French
Sarah Egan
Using GoConqr to teach science
Sarah Egan
Using GoConqr to study geography
Sarah Egan
Using GoConqr to study Economics
Sarah Egan
Using GoConqr to study English literature
Sarah Egan
Using GoConqr to learn French
Sarah Egan
A Level: English language and literature techniques = Structure
Jessica 'JessieB
A Level: English language and literature technique = Dramatic terms
Jessica 'JessieB