In this code you will find a number of problems for a total of 50 points You nee
ID: 3789111 • Letter: I
Question
In this code you will find a number of problems for a total of 50 points You need to identify three instances of notation 15 points You will need to identify when it is using a Linked List for a stack points You will need to identify where is using a sort and the type of sort it is 15 points where a recursive method is broken and why it is broken 10 points Name: Date public class MidtermCodelcsIS2420 extends comparable private double lowTemp new double[10] public void weekLowCEDJ to f int CJ week temp new int [t.length] int the Low; for (int i 0: i weektempo length: i++) t the Low for (int k i 1; k weektemp. length; k++) if CweektempttheLowl) 0) t theLow i) if (theLow swap Cweektemp, i theLow) private Strin ce12far(double temp) f Double Celsius temp string tempstring Celsius celsius is ((celsius 9 5.0) 32) Fahrenheit return tempstring public int newTemps (int[j temp) Link List st new LinkList 1; i++) 1 o: i temp length for (int i st push(tempi ij); return st.popO public int fixTempoint f) f int ret Temp 0; for (int k 0; k f; k++) retTemp f k; return retTemp; int tempchange (int number) if number 0) 1 return 1; tempchange i number, 1) Page 1Explanation / Answer
O(n^2) instances:
1. weekLow(E[] t) : this methods contains two for loop that is taking O(n^2)
2. checktemp(int n) : two for loop
3. adjustTemp(double t) : this methods has a for loop and inside that it is calling fixTemp() method that takes O(n)
so, overall O(n^2)
LinkedList uses:
newTemps(int[] temp) : in this method , linkeslist is being used as stack
Sorting :
weekLow(E[] t) : It this method, 't' parameter is getting sorted using SELECTION SORT
Recursive Method:
tempChange_i(): method calling itself recursively.
Here, specified base condition(condition to stop recursion) never get evaluates to true, so, it will never end
Please let me know in case of any issue
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.