Same circumference circular rings in a pole
: The rings havingsame circumference placed into a pole also follow LIFO strategy.The topmost ring, which was the last to be placed in the pole, is thefirst one to be taken out.
The bolts screwed to a single nut
: When the bolts are screwed to asingle nut, the last screwed bolt is unscrewed first and the bolt thatwas screwed first is unscrewed in the last.
Battery cells in a torch
: The battery cells in a torch also follow thesame LIFO strategy of stack.3) Differentiate full and complete binary trees.Ans:- The following table lists the differences between complete binarytrees and full binary trees:
Complete binary trees Full binary trees
All the nodes at the previous level are fullyaccommodated before thenext level is accommodated. All levels are maximallyaccommodated. Number of nodes at the last (n) level may or may not equal to 2
. Number of nodes at the last (n)level is exactly equal to 2
. Leaf nodes may or may not be at the same level. All leaf nodes are at the samelevel. A complete binary tree mayor may not be full binarytree. A full binary tree is always acomplete binary tree.
4) What are the demerits of recursion?Ans:- Demerits of recursion are:Many programming languages do not support recursion; hence,recursive mathematical function is implemented using iterativemethods.Even though mathematical functions can be easily implemented usingrecursion, it is always at the cost of execution time and memory space.