Taiwo A.

asked • 04/08/22

How do i finish the implementation of the method insertInOrder.

This method appends the record 'newData' into the correct sorted position in the linked list. If the list is empty, make the new node the head node of the list (i.e., have the head pointer point to it).


23 // Create a new node to hold the record.
24 //Replace this with the code necessary to create a new node to hold
25 //the record.
26
27
28
29 //Replace this with the code:
30 //if (expression to check if the list is empty)
31 //{
32 // code to make the new node the head of the list
33 //}
34
35
36
37
38
39 //Replace this with the code:
40 //else if (expression to check if the new acctNum is less than the head accNum)
41 //{
42 // code to make the new node the head of the list
43 //}
44
45 else
46 {
47 // put the new node where it belongs.
48 //Replace this with the code necessary to traverse the list and find the
49 //correct location for the new node to go.
50
51
52
53
54
55
56 //Replace this with the code necessary to insert the new node into the list
57
58 }
59 }//end of insertInOrder function
60


1 Expert Answer

By:

Donald W. answered • 04/08/22

Tutor
5.0 (214)

Senior Software Engineer with over 25 years of industry experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.