Program 1: Stack - Last In First Out |
|
Twinkle twinkle little star. How I wish I was where you are. |
|
Star little twinkle Twinkle. Are you where was I wish I how. |
Program 2: Stack with Backtracking |
|
This program will read an infix expression and convert it to a postfix expression. Enter an infix expression (do not use spaces): X+Y*Z This expression converted to postfix is XYZ*+ Enter an infix expression (do not use spaces): X+Y*Z/X This expression converted to postfix is XYZ*X/+ Enter an infix expression (do not use spaces): A+B*C*D+E This expression converted to postfix is ABC*D*+E+ |
Program 3: Implementing and Testing a Queue Class |
| Queue | Action |
| Bobo Ruth Ned Sam Ari Barb Lucy | Remove Bobo and Ruth from the front and add them to the end. |
| Ned Sam Ari Barb Lucy Bobo Ruth | Remove Ned |
| Sam Ari Barb Lucy Bobo Ruth | Move Sam and Ari to the end of the list. |
| Barb Lucy Bobo Ruth Sam Ari | Remove Barb |
| Lucy Bobo Ruth Sam Ari | Move Lucy and Bobo to the end of the list. |
| Ruth Sam Ari Lucy Bobo | Remove Ruth |
| Sam Ari Lucy Bobo | Move Sam and Ari to the end of the list. |
| Lucy Bobo Sam Ari | Remove Lucy |
| Bobo Sam Ari | Move Bobo and Sam to the end of the list. |
| Ari Bobo Sam | Remove Ari |
| Bobo Sam | Move Bobo and Sam to the end of the list. |
| Bobo Sam | Remove Bobo |
| Sam | Sam is the only person left in line therefore she is IT. |
Extra Credit |
|
Enter an infix expression (do not use spaces): (X+Y)*Z This expression converted to postfix is XY+Z* Enter an infix expression (do not use spaces): (X+Y)/(X-Y) This expression converted to postfix is XY+XY-/ |