Skip to content
Related Articles
Open in App
Not now

Related Articles

Data Structures | Misc | Question 1

Improve Article
Save Article
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!