1. Engineering
  2. Computer Science
  3. tmobile wifi ef1157 hw02docx cmpscf265 assignment 2 spring 2019 due...

Question: tmobile wifi ef1157 hw02docx cmpscf265 assignment 2 spring 2019 due...

Question details


T-Mobile Wi-Fi EF11:57 HW02.docx CMPSC-F265 Assignment 2 Spring 2019 Due: Saturday 2/2/2019 11:59pm ET Rules: Follow the submission instruction at the end of this document. Implementation should be in Java. Do it yourself. Also, you must abide by the academic integrity policy as determined by the school and mentioned in the course syllabus Your program MUST run without errors. Problem 1 (20 points) let n be the size of input, given the number of steps for different algorithms in the following table, write down the corresponding big O complexity. The symbol means to the power of, So n2 means n to the power of 2. Number of stepsComplexity order (big O) n(n + log(10)) log(5) (2 n)
Problem 2 (30 points) Determine the complexity order (big O) for each of the following codes part a for (int i-0; i(2*n+1); i++) //some statement part b) for (int i=1; ism i-i2) for (int j-0; j<n; j+) I/some statement part c) for (int i-5; ism i++) for (int j-0; j<m; j++) for (int k-0; k<n; k+H) //some statement
Problem 3 (50 points) part a) Write a method called hasDuplicate0 that takes as input an array of numbers and returns true if there is a duplicate number in the array, and returns false if array consists of unique numbers. For example, given [100, 4, 2, 2] your method should return true(since 2 is repeated), but given [1, 5, 2], your method should return false (since no element is repeated) public boolean hasDuplicate (intl] numbersArray) write your code here part b) Write a method called findMissingNumber that takes as input an array of distinct numbers from 0, 1, 2, .. n, and returns the missing number in that sequence. Note that the input array is sorted. For example, given [0, 1, 2, 4], your method should return 3. The time complexity should be in O(log(n)) (Hint: modify the binary search algorithm) public int findMissingNumber(int[] numbersArray) write your code here
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution