Skip to content
Related Articles

Related Articles

Data Structures | Misc | Question 1
  • Last Updated : 12 Feb, 2013
GeeksforGeeks - Summer Carnival Banner

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :