Question

In: Computer Science

   * Add operation counts    * f(N) formula (show your work)    * O(N) reduction...


   * Add operation counts
   * f(N) formula (show your work)
   * O(N) reduction
   */
   public static long sum3(int N)//f(N) = ; O(N) =
   {
       long opCount = 0;
       long sum = 0;
       for(int i = 0; i < N; i++)
       {
           for(int j = 0; j < N*N; j++)
           {
               sum++;
           }
       }
       System.out.println("f(N) = [your answer]");
       System.out.println("O(N) = [your answer]");
       System.out.println("OpCount : "+opCount);
       return sum;

Solutions

Expert Solution

        public static long sum3(int N)// f(N) = ; O(N) =
        {
                long opCount = 0;
                long sum = 0;
                for (int i = 0; i < N; i++)
                {
                        for (int j = 0; j < N * N; j++)
                        {
                                opCount++;
                                sum++;
                        }
                }
                
                /*
                 * The Outer loop runs N times.. For each outer loop, the
                 * inner loop is run N^2 times.. Hence total opCount 
                 * will be N^3.
                 * 
                 * Hence f(n) = n^3
                 * O(N) = O(N^3)
                 */

                System.out.println("f(N) = " + (N * N * N));
                System.out.println("O(N) = " + (N*N*N));
                System.out.println("OpCount : " + opCount);

                return sum;

        }
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

* Add operation counts -    * f(N) formula (show your work) -    * O(N)...
* Add operation counts -    * f(N) formula (show your work) -    * O(N) reduction -    */    public static long sum4(int N)//f(N) = ; O(N) =    {        long opCount = 0;        long sum = 0; // 1        for(int i = 0; i < N; i++)        {            for(int j = 0; j < i; j++)            {                sum++;   ...
/*    * Add operation counts    * f(N) formula (show your work)    * O(N)...
/*    * Add operation counts    * f(N) formula (show your work)    * O(N) reduction -    */    public static long sum2(int N)//f(N) = ; O(N) =    {        long opCount = 0;        long sum = 0;        for(int i = 0; i < N; i++)        {            for(int j = 0; j < N; j++)            {                sum++;           ...
Does this look correct? Add operation counts - 0.5pt    * f(N) formula (show your work)...
Does this look correct? Add operation counts - 0.5pt    * f(N) formula (show your work) - 0.5pt    * O(N) reduction - 0.5pt public static long sum1(int N)//f(N) = ; O(N) =    {        long opCount = 0;        long sum = 0; //1        opCount++;        opCount++;        opCount++;        for(int i = 0; i < N; i++) //2 + 2N        {            sum++; //N       ...
1.)Prove that f(n) = O(g(n)), given: F(n) = 2n + 10; g(n) = n 2.)Show that...
1.)Prove that f(n) = O(g(n)), given: F(n) = 2n + 10; g(n) = n 2.)Show that 5n2 – 15n + 100 is Θ(n2 ) 3.)Is 5n2 O(n)?
Correctly follow the described algorithm to complete the method    * Add operation counts -   ...
Correctly follow the described algorithm to complete the method    * Add operation counts -    * f(N) formula (show your work) -    * O(N) reduction -    */    public static int[] algorithm1(int N)//f(N) = ; O(N) =    {        long opCount = 0;        int[] arr = new int[N];        /*        * Use the following method to fill the array        * For each position in the array, generate a...
If f(n) = 3n+2 and g(n) = n, then Prove that f(n) = O (g(n))
If f(n) = 3n+2 and g(n) = n, then Prove that f(n) = O (g(n))
Use Excel to show your work and include the formula in the cell to show how...
Use Excel to show your work and include the formula in the cell to show how you arrived at your figures. Round percentages (example if 49.2, round to 49). Background: ABC, Inc., produces widgets. The company manufactures three levels of widgets-Economy, Better and Best. Selected information on the widgets is given below. Economy Better Best Selling price per widget $40.00 $60.00 $90.00 Variable expense per widget production $22.00 $27.00 $31.50 Selling (5% of selling price) $2.00 $3.00 $4.50 All sales...
Show that 2nlog(n) + 10n + 3log(n) + 6 is O(nlog(n)). Justify your answer by providing...
Show that 2nlog(n) + 10n + 3log(n) + 6 is O(nlog(n)). Justify your answer by providing a real-valued constant c > 0, corresponding to the upper-bound constant factor, and an integer constant n0 ≥ 1, consistent with the definition of Big-Oh
Calculate the Big-O time complexity. Show work 1. n^2 + 3n + 2 2. (n^2 +...
Calculate the Big-O time complexity. Show work 1. n^2 + 3n + 2 2. (n^2 + n)(n ^2 + π/2 ) 3. 1 + 2 + 3 + · · · + n − 1 + n
Please show all your work step by step and all the formula that is used. This...
Please show all your work step by step and all the formula that is used. This is my 3rd time posting as people do not explain what they are doing. Therefore, do not answer if you can't explain. D. What is the present value (PV) of a 12-years lease arrangement with an interest rate of 7.5% that requires annual payments of $4250. Per year with first payment being due now? E. A recent college graduate hopes to have $200000. Saved...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT