Question: // code must be in java // please the method is not supposed to take an index as a parameter, it's supposed to go through

// code must be in java

// please the method is not supposed to take an index as a parameter, it's supposed to go through the list until it finds the number that is bigger and stops before it. a solution contained an index parameter and the other solution did not work.No need for tracing

Question#2. Consider the following output examples for answering the following questions [20 pints]:

Example 1:

Enter a numerical ascending list and a number to insert: 1256 4

The new list is 12456

Example 2:

Enter a numerical ascending list and a number to insert: 1256 8

The new list is 12568

Example 3:

Enter a numerical ascending list and a number to insert: 2567 1

The new list is 12567

Example 4:

Enter a numerical ascending list and a number to insert:

1356 6

No changes because 6 exist in the list

Write a main and recursive method called (insertNumber) that inserts a number in a list of ascending numbers and reserves the list order. The insert operation performs if the given number doesnt exist previously in the list. [15 points].

Trace the execution of insertNumber using example 1 and example 4, which are shown above [5 points].

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!