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 about 9 years ago
42
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

Newton's Three Laws of Motion
PatrickNoonan
The First, Second, Third and Fourth Crusades
adam.melling
Biology- Genes and Variation
Laura Perry
IB Bio - Mitosis Quiz
j. stu
AQA A2 Biology Unit 4: Populations
Charlotte Lloyd
All AS Maths Equations/Calculations and Questions
natashaaaa
Blood MCQs Physiology PMU 2nd Year
Med Student
1PR101 2.test - Část 6.
Nikola Truong
CST Module 6a
Jane Foltz
General Pathoanatomy Final MCQs (111-200)- 3rd Year- PMU
Med Student