- Computer Science Engineering (CSE)
- Design and Analysis of Algorithms
- What will be the time complexity of the ...

Q. |
## What will be the time complexity of the code to reverse stack recursively? |

A. | o(n) |

B. | o(n log n) |

C. | o(log n) |

D. | o(n2) |

Answer» D. o(n2) | |

Explanation: the recurrence relation for the recursive code to reverse stack will be given by-t(n)=t(n-1)+n.this is calculated to be equal to o(n2). |

View all MCQs in:
Design and Analysis of Algorithms

- What is the space complexity of program to reverse stack recursively?
- What is the time complexity of the program to reverse stack when linked list is used for its implementation?
- What is the time complexity of matrix multiplied recursively by Divide and Conquer Method?
- What is the time complexity of the above code used to reverse a string?
- What is the time complexity of the above recursive implementation used to reverse a string?
- Which of the following is considered as the top of the stack in the linked list implementation of the stack?
- Matrix A is of order 3*4 and Matrix B is of order 4*5. How many elements will be there in a matrix A*B multiplied recursively.
- Which of the following takes O(n) time in worst case in array implementation of stack?
- Is Coppersmith-Winograd algorithm better than Strassen’s algorithm in terms of time complexity?
- Which of the following sorting algorithm has best case time complexity of O(n2)?

Login to Continue

It will take less than 2 minutes

Report MCQ