Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions