Fichas
Stacks
Fichas del conjunto (8)
- 1What is a stack?A method for handling linear lists of data. Data is added/removed from the top of the structure. Known as Last In, First Out.
- 2What are the basic operations of a stack?Adding/Removing from the top. Checking if stack is empty/full
- 3What is a stack pointer?The top of the stack where data can be added. It will determine whether the stack is full or not.
- 4What happens if a stack is full or empty?An error message needs to be displayed.
- 5How do you push something onto a stack?* check if tail pointer is equal to max
* if so, output 'queue is full'
* if not increase tail pointer by 1
* then insert data in position of updated tail pointer - 6How do you pop something from a stack?* check if head pointer is greater than tail pointer
* if so, output queue is empty
* if not, increase head pointer by 1
* then output data from position of updated head pointer. - 7what is the pseudocode for the stack push algorithm?function push(newItem)
newItem = input("Enter")
max = 10
if stackPointer> max then
print ('queue is full')
else
stackPointer= stackPointer+ 1
stackPointer[stackPointer] = newItem
print (Item Added)
endif
endfunction - 8what is the pseudocode for the stack pop algorithm?function pop()
if stackPointer= 0 then
print ('error stack is empty')
else
print (stackPointer[StackPointer])
stackPointer = stackPointer - 1
endif
endfunction
Información
- Descripción
- A level Computer Science Fichas sobre Stacks, creado por Ariana Parr el 19/09/2021.
- Creado por
- Ariana Parr
- Visitas
- 0
- Valoración