Correct Answer - Option 1 : stack
Concept:
- A stack is an ordered list in which insertion and deletion are done at one end, called a top.
- The last element inserted is the first one to be deleted. Hence, it is called the Last in First out (LIFO) or First in Last out (FILO) list.
Explanation:
A recursive problem like the Tower of Hanoi can be rewritten using system stack or user-defined stack
Recurrence relation of tower of Hanoi: T(n) = 2T(n - 1) + 1
Number of moves required for n disc in a Tower of Hanoi is 2n – 1 = 27 – 1 = 127.
Stack underflow happens when one tries to pop (remove) an item from the stack when nothing is actually there to remove.