A2 Data Structures - Stacks and Queues

pstevens1963
Flashcards by pstevens1963, updated more than 1 year ago
pstevens1963
Created by pstevens1963 about 5 years ago
27
1

Description

Flashcards to support testing of data structures stacks and queues

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

Spanish Conversation Phrases
silviaod119
GCSE Biology Quiz
Andrea Leyden
Biology B1
Kelsey Phillips
Physics 1
Peter Hoskins
RadioTelefonia
Adriana Forero
Diagnostico Organizacional Mapa Conceptual
ana viviana ortega
Aumento de la densidad
julian david ramirez villegas
REGLAMENTO DE USO LEGAL, ADECUADO Y PROPORCIONAL DE LA FUERZA PARA LA POLICÍA NACIONAL DEL ECUADOR
edwin patrico
Cualidades de la Voz y Variedad Vocal "Expresión Oral"
Gressia Edith Velasquez
Inglés - Verbos Compuestos II (Phrasal Verbs)
ALLISSON LABRE VALERO
Apariencia
Jose Miguel Cadavid