Please answer ALL questions below: 1. If you add the letters A, B, C, and D in s
ID: 3666130 • Letter: P
Question
Please answer ALL questions below:
1. If you add the letters A, B, C, and D in sequence to a queue of characters and then remove them, in what order will they leave the queue?
2. What do the initially empty queues queue1 and queue2 “look like” after the following sequence of operations?.
queue1.enqueue(1)
queue1.enqueue(2)
queue2.enqueue(3)
queue2.enqueue(4)
queue1.dequeue( )
queueFront = queue2.peekFront( )
queue1.enqueue(queueFront)
queue1.enqueue(5)
queue2.dequeue( )
queue2.enqueue(6)
3. Trace the palindrome-recognition algorithm described in this section for each of the following strings of character:
a) abcda
b) radar
4. In the bank simulation problem, why is it impractical to read the entire input file and create a list of all arrival and departure events before the simulation begins?
5. For each of the following situations, which of these ADTs (1 through 6) would be most appropriate? (1) a queue; (2) a stack; (30 list; (4) a sorted list; (5) a priority queue; (6) none of these
a) The customers at a6deli counter who take numbers to mark their turn
b) An alphabetic list of names
c) Integers that need to be sorted
d) The boxes in a box trace of a recursive function
e) A grocery listed ordered by the occurrence of the items in the store
f) The items on a cash register tape
g) A word processor that allows you to correct typing errors by using the Backspace key
h) A program that uses backtracking
i) A list of ideas in chronological order
j) Airplanes that stack above a busy airport, waiting to land
k) People who are put on hold when they call for customer service
l) An employer who fires the most recently hired person
Explanation / Answer
1. If you add the letters A, B, C, and D in sequence to a queue of characters and then remove them, in what order will they leave the queue?
Sol. A,B,C,D
2. What do the initially empty queues queue1 and queue2 “look like” after the following sequence of operations?.
queue1.enqueue(1)
queue1.enqueue(2)
queue2.enqueue(3)
queue2.enqueue(4)
queue1.dequeue( )
queueFront = queue2.peekFront( )
queue1.enqueue(queueFront)
queue1.enqueue(5)
queue2.dequeue( )
queue2.enqueue(6)
Sol. Queue1 2,3,5
Queue2 4,6
3. Trace the palindrome-recognition algorithm described in this section for each of the following strings of character:
a) abcda not palindrome
b) radar palindrome
4. In the bank simulation problem, why is it impractical to read the entire input file and create a list of all arrival and departure events before the simulation begins?
5. For each of the following situations, which of these ADTs (1 through 6) would be most appropriate? (1) a queue; (2) a stack; (30 list; (4) a sorted list; (5) a priority queue; (6) none of these
a) The customers at a6deli counter who take numbers to mark their turn (priority queue)
b) An alphabetic list of names (sorted list)
c) Integers that need to be sorted (sorted list)
d) The boxes in a box trace of a recursive function (stack)
e) A grocery listed ordered by the occurrence of the items in the store (sorted list)
f) The items on a cash register tape (list)
g) A word processor that allows you to correct typing errors by using the Backspace key (none)
h) A program that uses backtracking (stack)
i) A list of ideas in chronological order (sorted list)
j) Airplanes that stack above a busy airport, waiting to land (queue)
k) People who are put on hold when they call for customer service (stack)
l) An employer who fires the most recently hired person (stack)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.