A2 Data Structures - Stacks and Queues

Description

Flashcards to support testing of data structures stacks and queues
pstevens1963
Flashcards by pstevens1963, updated more than 1 year ago
pstevens1963
Created by pstevens1963 over 8 years ago
41
1

Resource summary

Question Answer
Static Data Structure Has fixed size that cannot be changed whilst the program is running (i.e. during runtime)
Static Data Structure Example DIM names(1 to 100) AS String (set up a data structure to store 100 names) Or A Record Structure Or A two dimensional array
Static Data Structure Benefits Easier to program since storage requirements know in advance Allows direct(random) access to data Compiler can allocate space during compilation Easier to check for Overflow
Dynamic Data Structure Size can increase and decrease whilst the program is running (i.e. during runtime)
Static Data Structure Drawbacks Can waste a lot of memory space Programmer has to estimate space required
Dynamic Data Structure Examples Queue Stack Binary Tree Linked List
Dynamic Data Structure Benefits Makes efficient use of memory space Storage no longer required can be returned to the system to be used for other purposes
Dynamic Data Structure Drawbacks More difficult to program Takes longer to implement searches E.g. Linked List only allows serial searches
The Heap Area of memory used to handle dynamic data structures
Queue FIFO First in First Out type data structure
Queue Variables No in Queue Front Rear Max Value for Queue
Remove Data from a Queue (DeQueue) Check for Empty Queue(report error) Remove data pointed by front pointer Move front pointer to locate the previous item
Stack LIFO Last In First Out type data structure
Add data to a Queue (EnQueue) Check for Full Queue (report error) Allocate memory for new node if not empty Move rear pointer to new item Insert new item at end of queue
Push and Pop Push items onto a Stack Pop items off a stack
Stack Variables Top Max Number in Stack
Add data to Stack (Push) Check if Stack is full (report error) Increment stack pointer Add data item at pointer
Remove item from Stack (Pop) Check Stack is Empty (report error) Output data (stack pointer) Decrement stack pointer
Circular Queue Rear of Queue linked to Front of Queue More efficient use of Space If Front = Rear then Queue is Empty
Reverse items in a Queue Remove items from the queue and push onto a stack Pop items from a stack into a queue Items will now be reversed
What happens when a stack is full? An overflow exception occurs
In a queue, if the front and rear pointers are at the same location what does this mean? The queue is empty
What happens if you try and remove an item from an empty stack? Stack underflow occurs
Where is an item removed from a queue? The front
Where is an item removed from a stack? The top
Where is an item added to a queue? The rear
What is a Dynamic structure memory benefit Allocated memory cannot be returned to the system for other uses
What does a programmer have to do to implement a static data structure? Estimate the amount of memory to allocate
Show full summary Hide full summary

Similar

Jekyll and Hyde
elliesussex
Of Mice and Men
amyk4321
My SMART School Year Goals for 2015
Stephen Lang
Spanish Subjunctive
MrAbels
MATTERS OF LIFE AND DEATH - UNIT 1, SECTION 2 - RELIGIOUS STUDIES GCSE EDEXCEL
Khadijah Mohammed
Edexcel Additional Science Biology Topic 2- Life Processes
hchen8nrd
Edexcel Additional Science Biology Topic 1- Genes and Enzymes
hchen8nrd
AQA GCSE Chemistry Unit 2
Gabi Germain
Romeo + Juliet (Themes)
alexandra_m_
The Strange Case of Dr. Jekyll and Mr. Hyde
K d
French Revolution quiz
Sarah Egan