Question: A queue will be represented . The queue head is the left - most element. ( a ) A vector data structure has the following

A queue will be represented . The queue head is the left-most element.
(a) A vector data structure has the following operations:
new Vector v(L): creates data structure with L elements set to a default value
select(i): returns the ith element of v.
store(v, i, a): sets the ith element of v to a
Suppose we require a vector but we only have access to a queue.
Write a pseudocode function with header select(q, index) that returns a copy of
the element in position index of the queue q. For example,
select(< a,b,c,d >,3)returns a copy of c. You can assume there is a function
copy(e) which makes a copy of element e The queue should remain unchanged
upon return.
(b)Write a pseudocode function with header store(q, index, value) that
overwrites the element at position index of the queue, q, with value. q should
remain unchanged otherwise.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!