1) a)Imagine the contents of queue Q1 and queue Q2 are as shown. What would be t
ID: 3623631 • Letter: 1
Question
1)
a)Imagine the contents of queue Q1 and queue Q2 are as shown. What would be the content of Q3 after the following code is executed? The queue contents are shown front (left) to rear (right).
Q1: 42 30 41 31 14 20 25 14 10 11 12 15
Q2: 1 4 5 4 10 13
1 Q3 = createQueue()
2 count = 0
3 loop ( not empty Q1 and not empty Q2 )
1 count = count + 1
2 dequeue (Q1, x)
3 dequeue (Q2, y)
4 if ( y equal count )
1 enqueue (Q3, x)
b)
Using the modulo division method and linear probing, store the keys shown below in an array with 19 elements. How many collisions occurred? What is the density of the list after all keys have been inserted?
224562, 137456, 214562
140145, 214576, 162145
144467, 199645, 234534
Explanation / Answer
There are really two unrelated questions here so you need to post them separately. I will answer (a).
Q3 will be 42,31.
y (the element removed from Q2) will equal count when count is 1 and 4 (when the elements 1 and 4 come up in Q2). At those points, x is, respectively, 42 and 31, so those values will be added to Q3 in that order.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.