I keep reading and reading about stacks but still I do not know how to use it in real world programming! I know it is a LIFO Data Structure but how can I benefit from this? I know the POP and PUSH functions, but so what?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here are some places where a stack can be useful: Any time you need to parse a string that uses parentheses for grouping, you need a stack. If you need to traverse a tree depth-first - for example, to convert an internal representation of an XML file to an XML file, or to compute the value of an expression that has been given by the user – you need a stack. Of course, in most such situations, you can avoid using it explicitly by using recursion (behind the scenes, the compiler uses a stack to implement it), but then you risk an implicit stack overflow that you can’t guard against.