i m learning algorithm for changing Ith element of stack
so change algorithm is
CHANGE(S,TOP,I)
1 if TOP -I +1 <=0
write('UNDERFLOW');
2 Return (S[TOP -I +1]
so in this algorithm what is I? I think it is index of element that we want to change..so if i have 3 elements in the stack S and i want to to change 3rd element then in 2 step top=3 - 3 +1 i.e 1 but it is last element.
For example my bottom of the stack element is 2 then 3 and then 4 so my TOP stack element is 4 and bottom of the stack element is 2...and bottom element index is 1 then 2 and then 3 so top element have index 3...
so how step 2 works?
if you don't want to give answer then don't but you cant say anything like that
i m beginner so my level is not as you have...i think you don't have answer of my question
The answers on all of your questions in the first post CSharpque:
so in this algorithm what is I?
The index from the top of the item you want to change.
so if i have 3 elements in the stack S and i want to to change 3rd element then in 2 step top=3 - 3 +1 i.e 1 but it is last element.
Yes.
For example my bottom of the stack element is 2 then 3 and then 4 so my TOP stack element is 4 and bottom of the stack element is 2...and bottom element index is 1 then 2 and then 3 so top element have index 3...