From the course: Nail Your C++ Interview

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Stacks in C++

Stacks in C++

- [Instructor] Stacks are another structure in C++ that are a great place for interview questions. A stack is a data structure that adds items to the back of the list and retrieves them the opposite way. If you think of a can of Pringles potato chips, they are loaded from the top, but the last chip in is the first chip out. First in last out, or FILO. In computer science, it's expected to know how to evaluate strings, either for natural language processing or an expression written in pre or postfix notation. Postfix notation is an arithmetic expression with the operators written after the operands. Let's take a look at how you would approach evaluating an arithmetic expression written in postfix notation using a stack. To use the stack in our program, we need to include the stack library. To declare a stack in our program, we simply use the stack keyword, give it a data type, and then a name. I've also declared a…

Contents