in DS
672 views
0 votes
0 votes
void f (queue Q) {
int i ;
if (!isEmpty(Q)) {
   i = delete(Q);
   f(Q);
   push(s, i);
  }
}
related to an answer for: GATE CSE 1994 | Question: 26
in DS
by
672 views

1 Answer

4 votes
4 votes
Best answer
Let size of queue  n and it is full filled.
Then function f(queue Q) will be called n times and every function call having a local variable i. (Untill last function call i.e. queue is empty all i variable should preserved).
So total n function call we need n local variable i.


Additional storage is not constant. It is order of n.
selected by

Related questions