Question: Construct a linked list using insertion sort (in Java) A text file contains a list of characters and their probabilities (opening the file in using
Construct a linked list using insertion sort (in Java)
A text file contains a list of characters and their probabilities (opening the file in using args)
Contents of text file:
a 30
b 25
c 15
d 10
e 20
Need the following two classes
- listNode class
- chStr (string)
- prob (int)
- next (listNode)
- constructor(s)
- linkedList class
- listHead (listNode)
- constructor(s)
- insertNewNode (listHead newNode)
- findSpot ()
- printList
listHead -->(dummy, 0, nexts chStr1)-->( chStr1, prob1, nexts chStr2)...... --> (chStrj,
Main
Step 1: listHead get a newNode as the dummy listNode with (dummy ,0), listHead to point to.
Step 2: chr : get from inFile
Prob : from inFile
newNode : get a new node
newNode.chStr : chr
newNode.prob : Prob
newNode.next : null
Step 3: insertNewNode
Step 4: printList(listHead)
Thankyou in advance.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
