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

Loading Question

asked in Programming by Veteran (10.5k points)   | 140 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 (285k 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 May 2017
  1. akash.dinkar12

    3146 Points

  2. pawan kumarln

    1608 Points

  3. sh!va

    1580 Points

  4. Arjun

    1326 Points

  5. Devshree Dubey

    1230 Points

  6. Angkit

    1028 Points

  7. Debashish Deka

    1012 Points

  8. Bikram

    970 Points

  9. LeenSharma

    810 Points

  10. srestha

    662 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. pawan kumarln

    234 Points

  2. Ahwan

    118 Points

  3. jjayantamahata

    106 Points

  4. joshi_nitish

    106 Points

  5. Aditya GN

    63 Points


22,722 questions
29,048 answers
65,039 comments
27,510 users