Question
Implement Shellsort for a linked list, based on a variant of bubble sort. The rather severe constraints imposed by the singly-linked list organization presents special
Implement Shellsort for a linked list, based on a variant of bubble sort. The rather severe constraints imposed by the singly-linked list organization presents special problems for implementing Shellsort. Your task is to overcome these constraints and develop a simple, elegant implementation that does not sacrifice efficiency or waste space. Step 1. First, implement a routine to build a list: read integers from standard input, and build a list node for each item consisting of an integer key and a link to the node for the next item. Also, write a routine to print out the contents of the linked list. Create a Class File for LinkedNode Implementation, and define a set of methods: LinkedNode() a constructor that initializes an Empty LinkedNode LinkedNode(T element) - a constructor that initializes an Empty LinkedNode with the given element. LinkedNode getNext() return the next node void setNext(LinkedNode node) set next to point to the node T getElement() return the element void setElement(T element) store the element in current node Note: Since we are sorting integers you can set the to be In your main Java file (controller), have the following methods: readValues(): read values from a file and build a linked list of integers. displayList(): Write a routine to display the contents of the linked list.
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