Question: java problem Question 3 (25 marks) We have seen in class two main ways of implementing a list: using an array or using linked elements.
Question 3 (25 marks) We have seen in class two main ways of implementing a list: using an array or using linked elements. We have also seen that both approaches each have strengths and weaknesses. In some cases, it could be useful to be able to switch between the two approaches, based on what the application is currently doing. Our goal is to provide a hybrid implementation. That implementation provides both an array implemen- tation and a linked-list implementation, albeit not at the same time. The linked-list implementation uses a singly-list approach (with no dummy node). The array implementation uses a simple array (no circular array). In order to support both implementations, our HybridList class will have the following instance variables: . headNode is a reference pointing at the first Node of a non-empty list. . headArray is a reference variable pointing to the array. currentSize is a primitive variable which holds the current number of elements in the list. currentCapacity is a primitive variable which holds the current capacity for the array Finally, isArray is primitive variable used to record whether the object is currently using an array linked-list to store the list's elements. The code below shows the beginning of the implementation. public elass HybridList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
