Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solution as java code please The goal of this assignment is to implement a dynamic array for some of the data structures we covered in

solution as java code please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
The goal of this assignment is to implement a dynamic array for some of the data structures we covered in this course. The size of the array that holds the data structure is static. Thus, when the data structure is full and the user tries to add a new element, an error occurs. Your goal is to 'grow' the array when some space is needed. When inserting a new element and the array is full, we do the following: 1- Allocate a new array temp with a capacity that is twice as large as the original array (for example A). 2- Copy all the elements from the original array to the new array, temp. When copying the elements, you must make sure that the structure is correct. For example, when you copy the heap, the maximum element will stay as the maximum element. For Queue, the front element will not be changed. The index of the front element might need to be changed. For Hash, you must hash the elements when you copy them to the temp array. 3- Make the original array variable points to the new array temp (e.g., A= temp). You must implement the expand0 method in the four classes, ArrayStack, ArrayQueue, HeapPriorityQueue, and LinearProbingHashTable. The expand method is already added to the class and some code is provided. You should complete the implementation. Make sure the testing code provided in TestingAssignment2. java is working correctly for each testing method: testingStack(), testingQueue(), testingHeapPriorityQueue(), and testingLinearProbingHashTable(). Expected Output: wxifesting expanding the size of the queuerwe This queue should double in 5120 each tine Initiol capocity is 10 At enqueve 11 Copacity increased to 20 At enqueve 21 Capacity increased to 40 At enqueve 41 Capacity increased to 80 At enqueve 81 Capacity increased to 160 At enqueve 161 capacity increased to 320 At enqueve 321 . Capac1ty Increased to 640 At enqueve 641 Capacity Inereased to 1280. Front elument of testqueve 3 Front elenent of teatoveue 8 I af elenents in testqueve: 998 swertenting expanding the istie of the heaptest This Priority Queve should double in sire each tine Inftiat cepacity is 18 At insert 11 Capacity increased te 20 . At insent 21 Capecity Increased to 40 At insent 41 Capaeity increosed to 00 At insert. 84 capecity Ancreased to 160 At Insert 161 Capadity Increased to 520 At Insent 323 Capacity increased te 060 At insurt 641 Eapacity incereased te 1200 A of elesents in testPQi 19Si Frent eleeent of testP0 (1000,A) Front eleaent of testho (PQ,A) \& ef etenonte in cestbe sasbresting exponding the size of the Linear Probing kash Tablowsen This Hash Table should double in 5ize each tine Initial capacity is 18 At Insect 11 Capacity lacreased to 28 At. insert 21 copacfity increased to 40 At insent 41 Copacity increased to 80 At Insert 81 Capacity ineceased 160 At Insert 101 Capaeity Increased to 320 At insent 321 Capacity increased to 640 At insert b41 cepocity Increased to 12% Content of the Mash: Content of the Nash: searchi far 1001 returns lin : 0

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

Logidata+ Deductive Databases With Complex Objects Lncs 701

Authors: Paolo Atzeni

1st Edition

354056974X, 978-3540569749

More Books

Students also viewed these Databases questions

Question

Ensure continued excellence in people management.

Answered: 1 week ago

Question

Enhance the international team by recruiting the best people.

Answered: 1 week ago