Data Structures | Misc | Question 1
Which data structure is used for balancing of symbols?
(A) Stack
(B) Queue
(C) Tree
(D) Graph
Answer: (A)
Explanation: Stack is used for balancing of symbols. This is extensively used by the compiler to check for missing or additional symbols. The start of the symbol(like (, [, {) are pushed to the stack. When the end of the symbol(like ), \, }) are encountered, it is matched with the corresponding peek element of the stack. If the match is found, the element is popped, else error is flashed.
Quiz of this Question
Please Login to comment...