Ask Question
30 October, 13:16

How does a linear algorithm perform compared to a quadratic one on our imaginary race track?

+4
Answers (1)
  1. 30 October, 17:15
    0
    The linear algorithms have the efficiency O (n). And their speed is always constant. And we need to calculate the efficiency of each of the algorithms for better management and application performance. If the input is big enough then quadratic algorithms O (N*N) always perform below a linear algorithm. And hence, linear programs are better.

    Explanation:

    Let us take an example of single for loop.

    for i in range (1,10):

    print (x)

    and second one:

    for i in range (1,10):

    for j in range (1,10):

    print (i*j)

    In the first single for look the algorithm is linear and it runs for 10 times, and when we increase range to 100 then it runs for 100 times. or O (N) times. However, when we consider two for loops in nested form then, it runs for 10 * 10 = 100 times and when we increase to 100 then it becomes, 100*100=10000 times. Thus, its complexity is O (N*N). Hence, quadratic algorithms are more complex and takes longer time to be solved.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How does a linear algorithm perform compared to a quadratic one on our imaginary race track? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers