Computer Science 2 PowerPoint PPT Presentation

presentation player overlay
1 / 5
About This Presentation
Transcript and Presenter's Notes

Title: Computer Science 2


1
Computer Science 2
  • Queue

2
Review
  • What is a stack?
  • What is a Queue?
  • What is a linked list?
  • What are some commands that go with dynamics?

3
Warm-up
  • What does a stack look like after the following?
  • Push 10, 20, 5, 16
  • Pop Two Values
  • Push 8
  • Pop 2 Values
  • Push 47, 18
  • What does a Queue look like after the following?
  • Enqueue (Add) 5, 12, 27
  • Dequeue (Remove) 2 values
  • Enqueue 51, 12, 92, 26
  • Dequeue 2 values

4
How can a Queue work?
  • For each of the following, consider the cases
    where... The Queue is empty, there is only one
    item, and there are many items.
  • What pointers should you have to keep track of a
    line (Queue)?
  • How would you add to the Queue?
  • How would you show the Queue?
  • How would you delete from a Queue?

5
Program options
  • Write a program that will model a line in a bank.
    (Menue with a while loop)
  • Add person to the line. Get their name and put
    them in the line.
  • Show all of the people in the line.
  • Serve a person. Say the name of the person being
    served.
  • Close the bank. (When this is chosen, everyone
    left in the line is dismissed personally. Ex.
    Sorry we are closed, please come back tomorrow,
    John, Jan , Jane, Jal,)
  • Push
  • Time how long each person waits in the line.
  • Add a provision for a person cutting in line.
  • Create a screen saver that uses a queue help
    modeling the motion. Line the lines around the
    screen saver where the lines are added to one end
    of the series and the line in the back of the
    series is removed. Note You need to
    incorporate the pointers into this option.
Write a Comment
User Comments (0)
About PowerShow.com