retagged by
6,380 views
2 votes
2 votes

Following is C like Pseudo code of a function that takes a number as an argument, and uses a stack S to do processing. 

void fun(int n) 
{ 
Stack S;//Say it creates an empty stack S 
while(n>0) 
{ 
 // This line pushes the value of n%2 to stack S; 
 Push(&S,n%2); 
 n=n/2; 
} 
// Run while Stack S is not empty 
while(!is Empty(&S))
printf("%d",pop(&S));//pop an element from S and print it 
} 

What does the above function do in general ?

  1. Prints binary representation of $n$ in reverse order.
  2. Prints binary representation of $n$.
  3. Prints the value of $\log n$.
  4. Prints the value of $\log n$ in reverse order.
retagged by

2 Answers

Answer:

Related questions

2 votes
2 votes
4 answers
1
admin asked Mar 30, 2020
1,631 views
Bug meansA logical error in a programA difficult syntax error in a programDocumenting programs using an efficient documentation toolAll of the above
0 votes
0 votes
0 answers
3
admin asked Mar 30, 2020
1,166 views
Which of the following statements is/are TRUE for an undirected graph?Number of odd degree vertices is evenSum of degrees of all vertices is evenP onlyQ onlyBoth P and QN...