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

Loading Question

asked in Programming by Veteran (10.6k points)   | 146 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 (286k 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 Jun 2017
  1. Bikram

    3704 Points

  2. Hemant Parihar

    1484 Points

  3. junaid ahmad

    1432 Points

  4. Arnab Bhadra

    1408 Points

  5. Niraj Singh 2

    1311 Points

  6. Rupendra Choudhary

    1194 Points

  7. rahul sharma 5

    1132 Points

  8. Debashish Deka

    994 Points

  9. srestha

    932 Points

  10. Arjun

    930 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 19 - 25
  1. Bikram

    1960 Points

  2. Niraj Singh 2

    1306 Points

  3. junaid ahmad

    502 Points

  4. sudsho

    410 Points

  5. akankshadewangan24

    388 Points


23,355 questions
30,066 answers
67,371 comments
28,382 users