Q3 (B) The performance of an algorithm can be determined in terms of its time and space complexity. Explain the difference between time complexity and space complexity and make a case for which is the most efficient method for determining the performance of an algorithm. [7 marks]
Time complexity is an estimate function that allows you to estimate how fast an algorithm is performing. Space complexity allows you to estimate how much extra memory an algorithm uses at runtime. Accordingly, the difference between them is the things they evaluate, one evaluates time, the other evaluates additional memory. It is impossible to say which method is the most effective for evaluating the algorithm, because no matter how fast your algorithm works, but if it is not optimized for memory use, it simply may not run on a computer that has little memory, on the other hand, speed is also an important parameter because most often, tasks need to be completed in real time. Therefore, to evaluate the algorithm, both methods must be applied: time estimation and space estimation. And only in some cases, when memory or time costs are not important, the algorithm should be estimated using one of the methods.
Comments
Leave a comment