CSCI 2315 Data Structures Spring 2017 Assignment 1 Dues Wednesday 02/15/2017 by
ID: 3790650 • Letter: C
Question
CSCI 2315 Data Structures Spring 2017 Assignment 1 Dues Wednesday 02/15/2017 by 11:59pm Part 1 osof the assegnementsrase Provide the notation for the foliowing lines of Java code, make sure you include allthenecessary steps to reach your answer to receive any credit: mij whaellen/2) 4 x k n; while (k 1) Part 2 In this part of the assignment, vou are to write a java program that reads a singleinteger from standard input. Upon reading this single integer, yourprogram should checkto see if the value entered is actually an integer, if not, then print an error and exit itis an integer, your program should make sure that the number is actually positive single digt, ifnot then print another error and exit the program Atter vouExplanation / Answer
Part 1 a.) since both the loop are independent of each other. Therefore, total running complexity is product of time taken by each loop. The outer loop runs n-18 times and inner loop will run log m times. Therefore, total time complexity is O(n logm).
b.) Similarly, since both the loop are independent of each other. Therefore, total running complexity is product of time taken by each loop. Outer loop will run m/2 times while inner loop run n/2 times. So, overall time complexity is O(mn).
c.) Outer while loop run log n times. Loop having variable i and j run n times. But this time both are running independently i.e., it will take total time of O(n) + O(n) = O(n). So, overall time complexity of the given code is O(nlogn).