Ask Question
25 February, 02:21

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

+3
Answers (1)
  1. 25 February, 02:49
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers