Basics of Time complexity and Space complexity

 It is a relation between Input Size & Running Time (operations). Time complexity represents the number of times a statement is executed.

a = int(input('Enter value: '));
for i in range(a):
    print(i)
Three types of Time complexity
  1. BEST CASE  
  2. AVERAGE CASE
  3. WORST CASE
1. Best case : it means the output found in 1st position. therefore time complexity is Î©(1).
2. Average Case :- Average over all possible input Î¸(n+1)/2
3. Worst case :- O(n)
a = int(input('Enter value: '))
for i in range(a):
    for j in range(a):
        print("hello", end=" ")
    print('\n')
aThe time complexity of this program is O(n²)

few Time complexity Examples
1. two input fields
a = int(input('Enter value: '));
b = int(input('enter value'))
for i in range(a):
    for j in range(b):
        print("hello", end=" ")
    print('\n')
the time complexity of this example is O(n * m)

2.  two input fields with two for loop
a = int(input('Enter value: '));
b = int(input('enter value'))
for i in range(a):
    print("hello", end=" ")
for j in range(b):
    print("hello", end=" ")
--> O(n+m)