answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ozzi
2 years ago
12

Prove that f(n) = 20n3 + 10nlogn + 5 is O(n3)

Computers and Technology
1 answer:
sp2606 [1]2 years ago
7 0

Answer:

The proof is in the explanation

Explanation:

f(n) is O(n^{3}) if f(n) \leq cn^{3} for n \geq n_{0}.

So, basically, we have to solve the following inequality

f(n) \leq cn^{3}

20n^{3} + 10n\log{n} + 5 \leq cn^{3}

Dividing everything by n^{3} to simplify, we have

20 + \frac{10\log{n}}{n^{2}} + \frac{5}{n^{3}} \leq cn^{3}

I am going to use n = n_{0} = 1. So

20 + 5 \leq c

c \geq 25

There is a solution for the inequality, which proves that f(n) = 20n^{3} + 10n\log{n} + 5 is O(n^{3})

You might be interested in
Meadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual
svp [43]

Answer:

Explanation:

import java.Util;

public class Eggs{

public static void main (String [] args)

{

int noOfEggs, dozen, units;

float total;

Scanner input = new Scanner(System.in);

noOfEggs = input.nextInt();

if(noOfEggs < 0)

{

System.out.print("Invalid");

}

else

{

if(noOfEggs >= 12)

{

dozen = noOfEggs/12;

units = noOfEggs % 12;

}

else

{

dozen = 0;

units = noOfEggs;

}

total = dozen * 3.25 + (units * 45)/100;

System.out.print("You ordered "+noOfEggs+" eggs.\n");

System.out.print("That's "+dozen+" dozen at $3.25 per dozen and "+units+" loose eggs at 45 cents each for a total of $"+total);

}

}

}

7 0
2 years ago
The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided
poizon [28]

Answer:

The Java code is given below with appropriate comments for explanation

Explanation:

// java code to contradict birth day paradox

import java.util.Random;

public class BirthDayParadox

{

public static void main(String[] args)

{

   Random randNum = new Random();

   int people = 5;

   int[] birth_Day = new int[365+1];

   // setting up birthsdays

   for (int i = 0; i < birth_Day.length; i++)

       birth_Day[i] = i + 1;

 

   int iteration;

   // varying number n

   while (people <= 100)

   {

       System.out.println("Number of people: " + people);

       // creating new birth day array

       int[] newbirth_Day = new int[people];

       int count = 0;

       iteration = 100000;

       while(iteration != 0)

       {

           count = 0;

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               // generating random birth day

               int day = randNum.nextInt(365);

               newbirth_Day[i] = birth_Day[day];

           }

           // check for same birthdays

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               int bday = newbirth_Day[i];

               for (int j = i+1; j < newbirth_Day.length; j++)

               {

                   if (bday == newbirth_Day[j])

                   {

                       count++;

                       break;

                   }

               }

           }

           iteration = iteration - 1;

       }

       System.out.println("Probability: " + count + "/" + 100000);

       System.out.println();

       people += 5;

   }

}

}

4 0
2 years ago
Write the printitem() method for the base class. sample output for below program: last name: smith first and last name: bill jon
ella [17]
The question involves basic polymorphism. The following is the partial flow of the program.

baseItemPtr = new BaseItem();
baseItemPtr.setLastName("Smith");

derivedItemPtr = new DerivedItem();
derivedItemPtr.setLastName("Jones");
derivedItemPtr.setFirstName("Bill");

itemList.add(baseItemPtr);
itemList.add(derivedItemPtr);

for (i = 0; i < itemList.size(); ++i) {
itemList.get(i).printItem();
}

return;
7 0
2 years ago
Read 2 more answers
Given a sorted array of integer, A, with possible duplicate elements. Implement an efficient (sublinear running time complexity)
allsm [11]

Answer:

The java program is as follows.

import java.util.*;

import java.lang.*;

public class SearchProgram

{

   // sorted array may or may not containing duplicate elements

   static int A[] = {-1, 2, 3, 5, 6, 6, 6, 9, 10};

   

   // variable to keep track of number of occurrences, declared and initialized to 0

   static int times=0;

   

// variable to hold value to be searched in the array

   static int key;

   static int search(int[] art, int n)

   {

       // enhanced for loop used to find how many times n occurs in array, arr

       for(int j:arr)

       {

           if(n == j)

               times = times+1;

       }

       

       return times;

   }

   

   public static void main(String[] args)

   {

       // scanner object to allow user input

       Scanner sc = new Scanner(System.in);

       

       // user prompted to enter key to be searched

       System.out.print("Enter the element to be searched: ");

       key = sc.nextInt();

       

       // message displayed to the user on how many times the element is present in the array

       System.out.println("The element " + key + " is present " + search(A, key) + " times in the array.");

   

   }

}

OUTPUT

Enter the element to be searched: 3

The element 3 is present 1 times in the array.

Explanation:

The steps of program execution are shown below.

1. An integer array, A, is declared and initialized.

2. An integer variable, times, is declared and initialized to 0.

3. A method, search(), is created which takes 2 parameters, array A and user entered value for the element to be searched in A.

4. The search() method has return type of integer and returns the value of variable, times.

5. Inside the search() method, an enhanced for loop is used to compute the value of the variable, times.

6. In the main() method, user is prompted to enter the value of key.

7. The search() is called and value of the variable, times, displayed to the user.

8. All the methods and variables are declared as static.

7 0
2 years ago
A network has N subscribers. Each subscriber is connected directly to all other subscribers.
enyata [817]
Ns me plz/..................

6 0
2 years ago
Other questions:
  • What are the two most important network-layer functions in a datagram network? what are the three most important network-layer f
    7·1 answer
  • A two-dimensional array can have elements of ________ data type(s).
    7·1 answer
  • A network administrator has received the IPv6 prefix 2001:DB8::/48 for subnetting. Assuming the administrator does not subnet in
    11·1 answer
  • 10) What is the BEST way to rewrite sentence (1) to make it more
    5·2 answers
  • Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value
    15·1 answer
  • Write a function that computes the average and standard deviation of four scores. The standard deviation is defined to be the sq
    15·1 answer
  • To operate a vehicle in Florida, you must _____.
    9·2 answers
  • Now that the classList Array has been implemented, we need to create methods to access the list items.
    5·1 answer
  • Which XP practice prescribes that "the code [always be] written by two programmers at one machine"?.
    13·1 answer
  • A major clothing retailer has requested help enhancing their online customer experience. How can Accenture apply Artificial Inte
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!