Computer Science, asked by devilbains1, 2 months ago

1. You have two algorithms A and B and
their complexities are determined by
these functions:
g(n) = n log n + 20 n and f(n) = 100
+ 3n² log n + n3/2
B is the better algorithm to use
because:

A) g(n) is O(n2 ) and f(n) is O(n3/2) and O(n2)
> O(n3/2).
B) g(n) is O(n) and f(n) is O(n2 log n) and
O(na) < O(n2 log n).
C) fn) is O(n3/2) and g(n) is O(n logn) and O(n
logn) < O(n3/2).
D) f(n) is oln2 log n) and g(n) is in log n)
and O(n log n) < O(n2 log n).​

Answers

Answered by Jasleen0599
0

Option D) f(n) is oln2 log n) and g(n) is in log n) and O(n log n) < O(n2 log n).​

You have two algorithms A and B and their complexities are determined by these functions: g(n) = n log n + 20 n and f(n) = 100 + 3n² log n + n3/2

B is the better algorithm to use because:

  • The length of the input determines how long it takes an algorithm to run, which is known as temporal complexity. It calculates how long it takes for each algorithm's code statement to run. It won't look at an algorithm's overall execution time.
  • Instead, it will provide details regarding the variation (increase or decrease) in execution time when an algorithm's number of operations (increase or decrease). Yes, as stated in the definition, the time required depends solely on the length of the input.
  • In computer programming, an algorithm is a finite series of precise instructions that are often carried out by a computer in order to solve a class of problems or carry out a particular activity.
  • According to the definition, for a computer to execute an algorithm or carry out a specified task, a set of defined instructions must be provided. In this situation, variations in the definitions of the instructions are possible. A specific set of instructions can be defined to carry out the same task in any number of different ways.

#SPJ1

Similar questions