CP164 Lecture Notes - Lecture 3: Binary Tree
Document Summary
Data structures has to be initialized (created food object) Eg kleenex (empty by pulling from top) Way to access information is by pulling it off the top or stacking on top. Cannot push" and pop" off binary tree. Natural way to use stack is add to top, take off the top ( last thing we put in is the first thing we take out) Method push: add element to top of stack (add data) Method pop: removes top element of stock. Method peek: can only peek at top ( return copy of the value at the top of the stack without removing it if one exists. Is empty: true if stack is empty, false if otherwise. Cpu (stack area of memory to make variables and function calls) Write an algorithm that uses stack to find exit of maze. Expression evaluation- take a mathematical expression and use stack to solve it (postfix expression)