Problem Set #4: Stacks and Queues

For this prefect session, we're going to use Stacks and Queues to solve various problems:

  1. Write a program that reads in a sequence of characters and prints them in reverse order. Use a stack.

  2. Write a program that reads in a sequence of characters, and determines whether its parentheses, braces, and curly braces are "balanced."

  3. Write a program that reads in a positive integer and prints the binary representation of that integer. Hint: divide the integer by 2.

  4. Write code to reverse the contents of a stack using a queue.

  5. Write code to reverse the contents of a queue using a stack.