Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 ................................................................................................................... [100 Marks] The goal of this assignment is to implement a dynamic array for some of the data structures we covered in
Question 1 ................................................................................................................... [100 Marks]
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.
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: testingStack(), testingQueue(), testingHeapPriorityQueue(), and testingLinearProbingHashTable().
(Codes files)
https://drive.google.com/drive/folders/11CnWkRPokS0aUYaIGpZc2E9gCJB_nzQQ
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started