[Solved] CS570-Assignment 2- implement a number of methods for a class Complexity

$25

File Name: CS570-Assignment_2-_implement_a_number_of_methods_for_a_class_Complexity.zip
File Size: 678.24 KB

SKU: [Solved] CS570-Assignment 2- implement a number of methods for a class Complexity Category: Tag:
5/5 - (1 vote)

Assignment

This assignment asks you to implement a number of methods for a class Complexity. These methods should be implemented using for loops, as seen in class (except for the extra-credit one). In addition, each of these methods should print out the value of an accumulator that counts the number of operations performed. The notion of operation should be taken loosely; the idea is that if you are requested to implement a method of time complexity O(n), then it should print out values from 1 to n (or close enough). For example, the following code implements a method that has time complexity O(n):

void public method0(int n) { int counter=0; for (i=0; i<n; i++) {System.out.println(Operation +counter); counter++;}}

2

4

6

The methods you should implement are:

  • public static void method1(int n): a method that has time complexity O(n2).
  • public static void method2(int n): a method that has time complexity O(n3).
  • public static void method3(int n): a method that has time complexity O(logn).
  • public static void method4(int n): a method that has time complexity O(nlogn).
  • public static void method5(int n): a method that has time complexity O(loglogn).
  • (Optional) public static int method6(int n): a method that has time complexity O(2n). For this method you should consider using recursion. This can give you extra points if you miss any points from the previous methods, but the cap for the assignment is 100pts. You can not exceed 100pts with answering this extra-credit question.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS570-Assignment 2- implement a number of methods for a class Complexity
$25