+ 1

What is stacking and push() and pop() functions ?? [In detail]

in terms of pointers if possible !!

9th Jan 2017, 12:38 PM
Siddharth Naithani
Siddharth Naithani - avatar
2 Answers
+ 5
stack is a data structure which saves data in the form of FILO (first in last out) the basic operations are push(val) and pop() push(val) puts val at the top of the stack pop() gets the last value that was pushed lets see a pseudo code example (stack values are pushed from left to right, meaning most left is the top) st = new stack() st: (empty) st.push(5) st: |5| st.push(8) st: |8|5| st.push(2) st: |2|8|5| x = st.pop() x: 2 st: |8|5| y = st.pop() y: 8 st: |5| as you can observe, the last value that can be popped is the one that was pushed first: 5, hence FILO and that's the basic stuff of it
9th Jan 2017, 4:43 PM
Burey
Burey - avatar
0
push() puts an element at the end of the stack
9th Jan 2017, 1:56 PM
Jonas Geiler
Jonas Geiler - avatar