Question: Question 1 [in Java please] !!!!! The goal of this assignment is to implement a dynamic array for some of the data structures we covered
Question 1 [in Java please] !!!!!
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:
- Allocate a new array temp with a capacity that is twice as large as the original array (for example A).
- 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.
- Make the original array variable points to the new array temp.
You must implement the expand 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: testingStack0, testingQueue0, testingHeapPriorityQueue0, and testingLinearProbingHashTable.
(Codes files)
https://drive.google.com/drive/folders/11CnWkRPokSOaUYalGpZc2E9gCJB_nzQQ


Expected Output: Whth Testing expanding the size of the quevektiki wekiesting expanding the size of the heaptew This Priority queve should double in size each tine Initial capacity is 10 At insert 11 Capacity increased to 28 At insert 21 Capacity increased to 40 At insert 41 Capacity increased to ge At insert 81 Capacity increased to 180 At insert 161 Capocity increased to 320 At insect 321 Capacity increased to 640 At insert 661 Capacity increased to 1280 * of elements in testPQ: 1060 Frent elenent of testPQ (1699,A) Front element of testPQ (999,A) \# of elements in testPQ: 998 . Teating stignmenc2. *tatiesting expanding the size of the Linear Probing Hash Tabletakt This Hash Tabte should double in size each tine Initiat capacity is 10 At insent 11 Capacity increased to 20 At insert 21 Capacity increased to 40 At insert 41 Copacity increased to 80 At insent 81 Capacity increased to 160 At insert 161 Cepacity increased to 320 At insert 321 Capacity increased to 640 At insert 641 Copacity increased to 1280 Content of the Hash: Content of the Hash: search for 1001 returns 8?:8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
