Q BgQuestion:

      
Pupil
Karma Points: 50
Respect (83%):
posted by  KOJ on 11/7/2009 6:32:05 AM  |  status: Closed  |  Earned Karma: 50

Queues Question !!

Course Textbook Chapter Problem Needs by
Data Structures C++ Programming: From Problem Analysis to Program Design (3rd) by Malik 19 18E 11/7/2009 at 12:00:00 PM
Question Details:
18)
Suppose that queue is implemented as an array with the special resrved slot, as described in this chapter. Suppose that the size of the array implementing queue is 100. Also, suppose that the value of queueFront is 74 and the value of queueRear is 99
a)
      what are the values of queueFront and queueRear after adding an elemen to queue ?
b)
      
      what are the values of queueFront and queueRear after removing an elemen to queue ? Also, what is the position of the removed queue element ?
Bonus Point Alert! Earn +15 additional karma points for helping this platinum member.

AAnswers:

Answer Question Ask for clarification
Oracle
Karma Points: 31,807
posted by rapunzel on 11/7/2009 8:53:12 AM  |  status: Live
Asker's Rating: Lifesaver   
Response Details:
please rate - thanks

18)
Suppose that queue is implemented as an array with the special resrved slot, as described in this chapter. Suppose that the size of the array implementing queue is 100. Also, suppose that the value of queueFront is 74 and the value of queueRear is 99
initial queue
 add at rear remove from front



a)
      what are the values of queueFront and queueRear after adding an elemen to queue ?

      
if add an element
queueFront=74      queueRear=0                 since 100 elements they are numbered 0-99 so after 99 go to 100

b)
      
      what are the values of queueFront and queueRear after removing an elemen to queue ? Also, what is the position of the removed queue element ?
if remove an element-assuming initial condition (as opposed to after part a)
queueFront=75      queueRear=99    

The position of the element was 75  (be careful that's different then it's index which is 74)
Note to all members 1. Please 1 question per post 2. Show respect to your fellow members by rating all answers. 3. When rating remember that the first answer is not necessarily the best answer. 4. When answering questions, explain what you are doing, so that the asker will learn, don't just give a meaningless number. 5. Your answers should be your work. Don't copy from another member, this is Karma abuse and possible disciplinary actions against you. and GOOD LUCK to you all!!
Answer Question Ask for clarificarion

Join Cramster's Community

Cramster.com brings together students, educators and subject enthusiasts in an online study community. With around-the-clock expert help and a community of over 100,000 knowledgeable members, you can find the help you need, whenever you need it. Join for free today » How Cramster is different from tutoring »