Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE IN JAVA Programming (non-collaborative)-Due at the end of Module 5. Consider the following im- plementation of a set. We use a pair of arrays

WRITE IN JAVAimage text in transcribed

Programming (non-collaborative)-Due at the end of Module 5. Consider the following im- plementation of a set. We use a pair of arrays where one array is longer than the other, and both arrays are kept sorted. The length of the shorter array is the square root of the length of the longer array; although, it may have empty entries if it is not yet full. To add an element, you use insertion sort to insert the element into the shorter array. If the short array fills up, re-allocate the shorter and longer arrays and merge the two old arrays into the new longer array. The new short array is empty. Then, to find an element, use binary search on both the long and the short arrays. (a) [50 points] Given this data structure, prove that the data structure yields O(lgn) time for searching but O(Vn) amortized time for adding an element. (b) [50 pointsl Implement the above data structure and insert/search operations. Test your imple- mentation to verify the predicted complexity bounds are achieved. Programming (non-collaborative)-Due at the end of Module 5. Consider the following im- plementation of a set. We use a pair of arrays where one array is longer than the other, and both arrays are kept sorted. The length of the shorter array is the square root of the length of the longer array; although, it may have empty entries if it is not yet full. To add an element, you use insertion sort to insert the element into the shorter array. If the short array fills up, re-allocate the shorter and longer arrays and merge the two old arrays into the new longer array. The new short array is empty. Then, to find an element, use binary search on both the long and the short arrays. (a) [50 points] Given this data structure, prove that the data structure yields O(lgn) time for searching but O(Vn) amortized time for adding an element. (b) [50 pointsl Implement the above data structure and insert/search operations. Test your imple- mentation to verify the predicted complexity bounds are achieved

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions