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.

java problem  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. We have also seen that both approaches each have strengths
and weaknesses. In some cases, it could be useful to be able

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 next: private Node (T value, Node headNode: private El1 headArray private int currentSize-0; private int currentCapacity -50 private boolean isArray false public boolean isEmpty Of return currentsize 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!