Computer Science, asked by leelaprasanth, 7 months ago

10. The time complexity of g(n, x, y) is O(n). What is the time complexity of f(n)?
def f(n):
if n == 1:
return 1
x = f(n/2)
y = f (n/2)
return g(n,x,y)
A: O(log n)
B:0(n)
c:O(n*log n)
D:O(n)​

Answers

Answered by Jasleen0599
0

Option : d) O(n)​

  • Big O Notation describes an algorithm's complexity as O(n). The size of the input is indicated by the number n, which in your instance is the number of items in your list. Your algorithm will insert an item in the sequence of n operations, or O(n).
  • You are faced with linear time complexity, sometimes known as O(1), when time complexity becomes directly proportionate to the quantity of the input (n). The input (n) will be processed by algorithms with this time complexity in "n" operations.
  • The Big O Notation for time complexity provides an approximation of the execution time of an algorithm based on the size of the input and the number of steps required to complete it. To calculate our runtime, we compare the two.
  • One technique to gauge an algorithm's effectiveness is through Big O Notation.
  • As the input increases, it calculates how long it takes to run your function. Or, how effectively does the function scale. The time complexity and the spatial complexity are the two components of efficiency measurement.

#SPJ3

Answered by aryansuts01
0

Answer:

The answer is Option [D]. O(n)​

Programmers can assess an algorithm's scalability using the Big-O notation. Based on the amount of data the programme must deal with, it shows the maximum number of operations that an algorithm can perform before producing a result.

Explanation:

One technique to gauge an algorithm's effectiveness is through Big O Notation. It determines how long it will take to execute your procedure as the input rises. Alternatively, how well does the expression scale. Effectiveness is evaluated using both temporal and spatial complexity.

The Big O notation is one of the basic techniques computer programmers use to assess an algorithm's complexity. It would be wise for software engineers to fully understand it as well.

We only consider the dominating term of the function when attempting to determine the Big O for a specific function g(n). The term that grows the quickest is the dominating term.

Since n2 increases more quickly than n, for instance, g(n) = n2 + 5n + 6 will be large O(n2). This is somewhat similar to the short cut for finding limits for fractional polynomials, where you only care about the dominating term for numerators and denominators at the conclusion, if you've taken calculus before.

#SPJ2

Similar questions