0% found this document useful (0 votes)
21 views1 page

Understanding Time and Space Complexity

The document explains space and time complexity, emphasizing their importance in evaluating algorithm performance based on input size. It distinguishes between best case and worst case performance, highlighting the significance of understanding these scenarios for practical applications. Additionally, it defines O(1) and O(n) notations, illustrating how they relate to execution time and space requirements in algorithms.

Uploaded by

richardkondowe8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Understanding Time and Space Complexity

The document explains space and time complexity, emphasizing their importance in evaluating algorithm performance based on input size. It distinguishes between best case and worst case performance, highlighting the significance of understanding these scenarios for practical applications. Additionally, it defines O(1) and O(n) notations, illustrating how they relate to execution time and space requirements in algorithms.

Uploaded by

richardkondowe8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Section A

Space complexity is amount of memory required by an algorithm to execute and get the result.

Time complexity is the amount time required to finish execution of an algorithm and get the result.

2. It is important because the algorithm performance is evaluated in terms of input size allowing to
estimate the performance levels with increase in the inputs by looking closely with how much space
and time it takes to execute.

3. allows us to predict how algorithms will will perform in real life scenarios

Allows us to compare and choose the suitable algorithm from a different algorithm when solving a
particular problem.

Section B

1. Best case performance is used to describe an algorithms performance under favourable


conditions where the algorithms takes minimal time and memory to solve a problem while
worst case performance describes an algorithms performance under unfavourable conditions
where the algorithm takes a lot of time and memory to solve a problem.
2. Understanding the worst case performance is crucial in life because it enables us to
understand the potential challenges that need to be addressed before hand.
3. a- O (1) stands for Constant time function/method that describes that an algorithm takes the
same amount of time to execute regardless of the size of inputs
- O(n) stands for Linear time function/ method that describes that time taken to execute
an algorithm depends on the size of the inputs.

c. in a linear time function, space complexity is describes that the space required to solve the
problem grows in relation to the size of the inputs.

You might also like