GATE CSE
First time here? Checkout the FAQ!
x
0 votes
121 views

Loading Question

asked in Programming by Loyal (3.8k points)   | 121 views
here what does w.r.t to Top means. Pop operation removes top element.  so value of I should be 0 or 1????
Is it option B ?
in key D os given but i think D is not answer.

1 Answer

+3 votes
Best answer
If we need to get $I^{th}$ element from Top, we require at least $I$ element in stack. So, $Top \geq I$ and underflow condition is $Top < I \\ \implies Top+1 \leq I \\ \implies Top -I+1 \leq 0$
answered by Veteran (272k points)  
selected by
supppose we have n=5 element,,and bottom of stack is 0 so top will be 4,,,now we want to delete 5th element wrt top(that is 0th element) now

top-i+1=4-5+1=0

so 0<=0 but no underflow....after this it can be underflow
@Arjun sir, if stack contains a,b,c,d,e,f and base-0 which contains a, and top will be be pointing to f, then what will be the 1 st elemtent wrt to top.??? e or f???
Top Users Jan 2017
  1. Debashish Deka

    7172 Points

  2. Habibkhan

    4696 Points

  3. Vijay Thakur

    4308 Points

  4. sudsho

    4090 Points

  5. saurabh rai

    4024 Points

  6. Arjun

    3292 Points

  7. santhoshdevulapally

    3066 Points

  8. GateSet

    3016 Points

  9. Bikram

    3014 Points

  10. Sushant Gokhale

    2892 Points

Monthly Topper: Rs. 500 gift card

18,838 questions
23,808 answers
51,588 comments
20,148 users