1answer.
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
Ksju [112]
3 years ago
15

What is the big-O performance estimate of the following function?

Computers and Technology
2 answers:
larisa [96]3 years ago
8 0

Answer:

The time complexity of the code is O(log₇n).

Explanation:

The i is updated by 7*i.On each iteration i is multiplied by 7.So on finding the time complexity of the code given above it will come out to  be log base 7.

When we divide the input by 2 the time complexity is log base 2.

So on dividing it by 7 we get the time complexity of log base 7.

Digiron [165]3 years ago
4 0

Answer:

Since the loop index variable i is initialized to 0, this function will result in infinite execution for all values of n>=0.

If instead the loop index variable is initialized to 1, Big O performance estimate of the code is O(log n) with logarithm base as 7.

Explanation:

Given function:

int f (n) {

int sum = 0;

for (i = 0; i < n; i = 7 * i)

sum += i;

return sum;

} // end f

The complexity is determined by the for loop. Starting value of the index variable i is 0.  At each iteration the value of the index variable i is multiplied by 7 (i=7*i). But multiplication by 7 still leaves the value of the index variable as 0. So loop condition i<n will fail for all n>=0 and the loop will continue indefinitely since the termination condition will never be achieved.

However if the loop index variable i is initialized to 1 instead, the loop will run O(log n) times with 7 as the base of the logarithm due to successive multiplication of index variable by 7 at each iteration.

You might be interested in
Machines may aid in making work easier over a longer distance. true or false.
Dmitry [639]
This seems like more of an opinion based question, but since they added "over a longer distance" If I were you I would go with false.
4 0
2 years ago
A computer processes data only using 1s and 0s
ArbitrLikvidat [17]
Yes it only processes data using 1s and 0s
8 0
3 years ago
Read 2 more answers
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
oksano4ka [1.4K]

Answer:

The program in Python is as follows:

def get_user_values():

   user_values = []

   n = int(input())

   for i in range(n+1):

       inp = int(input())

       user_values.append(inp)

   output_ints_less_than_or_equal_to_threshold(user_values,user_values[n])

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

   for i in user_values:

       if i <= upper_threshold:

           print(i,end=" ")

           

get_user_values()

Explanation:

This defins the get_user_values() method; it receives no parameter

def get_user_values():

This initializes user_values list

   user_values = []

This gets the number of inputs

   n = int(input())

This loop is repeated n+1 times to get all inputs and the upper threshold

<em>    for i in range(n+1):</em>

<em>        inp = int(input())</em>

<em>        user_values.append(inp)</em>

This passes the list and the upper threshold to the output..... list  output_ints_less_than_or_equal_to_threshold(user_values,user_values[n])

This defines the output.... list

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

This iterates through the list

   for i in user_values:

If current element is less or equal to the upper threshold, the element is printed

<em>        if i <= upper_threshold:</em>

<em>            print(i,end=" ")</em>

The main method begins here where the get_user_values() method is called

get_user_values()

7 0
2 years ago
One of the difficult decisions a systems analyst has to make when it comes to software is whether to recommend making, buying, o
Mademuasel [1]

Answer:

Explanation:

There are different advantages to buy commercial software like:

- Is a system used for other companies, we will have good referents with the feedback of them.

- Support, we should have support twenty-four hours, if a system doesn't have good support, we must not buy the software.

- We can choose software with a lower initial cost, this depends on our needs.

3 0
2 years ago
Web services can exchange information between two different systems only if the operating systems and programming languages upon
stich3 [128]
Because if im talking to someone in english but they are from china and communicating to me in chinese then thas what itll do
4 0
3 years ago
Other questions:
  • What were the first microblogs known as
    12·2 answers
  • ____ are systems in which queues of objects are waiting to be served by various servers
    5·1 answer
  • Explain possible consequences if someone is issued with a fraudulent licence
    6·1 answer
  • Bullets in a text box will do which of the following?
    9·2 answers
  • You can create a database using one of the many templates available or by creating a new ______ database.
    9·1 answer
  • What are the five types of alignment in Word?
    12·2 answers
  • Number 20, can anyone help?
    11·1 answer
  • Amy just added a 462 meter run of fiber optic cable to the network what should she do next?
    10·1 answer
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • Ano ang ibig sabihin ng tanka<br>​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!