1. Engineering
  2. Computer Science
  3. question 01 complexity analysis consider the following method one...

Question: question 01 complexity analysis consider the following method one...

Question details

Question 01: Complexity Analysis Consider the following method one.

Question 01: Complexity Analysis Consider the following method one. public static int one(int n)\ int x-0; for(int i-n*n; j>0; j-2) x +twoi); //statement 1 else for(int j-ij-iitt) x +three(i); return X:; public static int two(int n)\ int x-0; for(int i- n; i>n/2; i-) ㄨ廾://statement 2 return ntx public static int threefint n)i int x-0; for(int i-l; i <500; i*-2) x ++; //statement 3 return ntx It is assumed that each simple instruction such as addition, multiplication, division, comparison and assignment is O(1) 1. Count the number of times statementl, statement2 and statement3 get executed in terms of the input number n, 2. Express the overall cost of method one as a function/(n), where n is the problem size, by finding the cost of the most expensive operation. Clearly indicate that most expensive operation. Determine the Big-O) time complexity of method one. 3.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution