Need help with this Computer Science programming problem
b) 1 3 b) 1000 0 c) worst... View the full answer
- Numbering was incorrect. The corrected numbering is a) 1 3 b) 1000 0 c) worst case time complexity O(n) best case time complexity O(n)
- Mar 05, 2016 at 12:36am
- Could you explain how you got the answers?
- Mar 05, 2016 at 1:14am
- a) this program is trying to find the minimum number with its position .The first set the value to a large number so that all numbers are less than that to check.so here the minimum number is 1 at position 3 so value =1 and pos = 3.. b) as all the numbers in the array are greater than 1000 so the minimum remains the first value thats 1000 and pos was initialised as 0 so pos =0. c) the time complexity of a while loop is O(n) ...as the loop here can in no way have a best/optimised case so both best case and worst case time complexities are O(n)
- Mar 05, 2016 at 1:20am