Instructions
Programs that you write will be evaluated not only for the final output but also for the clarity and proper coding practices. For each question create a separate NetBeans project. Once you are done with all questions, zip them in a folder with the name “Assignment-4” and upload it to Canvas.
Question 1
Create a new linked list class(You can use the one I posted Canvas as a starting point) with the following new methods.
- An insertion routine which keeps the list in ascending order by using the insertion sort algorithm.
- A method which deletes duplicates of all elements from the list so that after running this function, each list element occurs only once.
- A method which counts the number of elements in the list.
Question 2
Design a class to implement bi-directional or symmetric linked list. Each element in a bi-directional list has two associated pointers: One pointing to the previous element in the list and the other to the following element. Design methods which allow insertion and deletion of elements from such a list, and provide appropriate constructors.
Question 3
Define a new class called PriorityQueue which is a queue in which each item is inserted in to the queue at a location determined by its priority. To keep things simple, assume that the elements in the queue are are simple ints.When a new int is added to the queue, it moves in front of all other elements in the queue whose values are greater than it. For example, if number 3 is to be added to the queue:
1, 1, 2, 4, 5, 7, 9
where the head of the queue is on the left, it would be inserted between the 2 and 4. Note that the only differences between a priority queue and an ordinary queue is in the insertion method. So all other methods may be directly get it from my code that I posted on Canvas.