Ask Question
21 April, 14:56

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

+1
Answers (1)
  1. 21 April, 16:31
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers