[Almost Done] Stacks | Data Structures - OCR Computer Science A Level

Description

A level Computer Science (Data Structures) Flashcards on [Almost Done] Stacks | Data Structures - OCR Computer Science A Level, created by Malachy Moran-Tun on 08/10/2021.
Malachy Moran-Tun
Flashcards by Malachy Moran-Tun, updated more than 1 year ago More Less
Malachy Moran-Tun
Created by Malachy Moran-Tun over 2 years ago
Malachy Moran-Tun
Copied by Malachy Moran-Tun over 2 years ago
3
0

Resource summary

Question Answer
What is a Stack? > Last in, first out (LIFO) data structure > Contains multiple elements, similar to a one-dimensional array > New elements can only be added to the top > Elements can only be retrieved from the top > Sequence of elements is determined by the order in which they are inserted
What are some Examples of Stacks being Used? > Back buttons in web browsers > Undo functions in various applications (e.g.: word processors, music software, etc.) > Hold return addresses when subroutines are called > Calculations (apparently)
What Operations can be Performed on a Stack? > push(item) - Adds a new item to the top of the stack > pop() - Removes the top item from the stack and returns it > peek() - Returns the top item from the stack (does not remove it) > isEmpty() - Returns true if the stack is empty, false if not > isFull() - Returns true if the stack is full, false if not
How can a Stack be Implemented with Static Data Structures? > Two additional variables are created > One pointer variable, which points to the top of the stack > One being the maximum size of the array, which is used to stop overflow in the stack
Why would isFull() or isEmpty() need to be Called when Adding or Popping an Item to a Stack? > If the stack is static, there will be a maximum size determined by the array size > If the pointer exceeds this size, an overflow error would occur, which could potentially crash the program, or write to unwanted memory, affecting it elsewhere > If the pointer goes below 0, an underflow error would occur if an attempt is made to pop an item, potentially causing a crash
Show full summary Hide full summary

Similar

Computing Hardware - CPU and Memory
ollietablet123
SFDC App Builder 2
Parker Webb-Mitchell
Data Types
Jacob Sedore
Intake7 BIM L1
Stanley Chia
Software Processes
Nurul Aiman Abdu
Design Patterns
Erica Solum
CCNA Answers – CCNA Exam
Abdul Demir
Abstraction
Shannon Anderson-Rush
Spyware
Sam2
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Data Analytics
anelvr