In: Computer Science
Answer: For Implementing this Algorithm we have taken the function which accepts the string when calling and then plotting the graph as string of length p takes 2 seconds to run.
Here is the code for the following algorithm:
import matplotlib.pyplot as plt
%matplotlib inline
def st(p):
num=len(p)
x=[]
y=[]
for i in range(1,9):
x.append(i*num/4)
for j in x:
y.append(2*j)
#print(x)
#print(y)
plt.plot(x,y)
plt.xlabel("Length of String")
plt.ylabel("Time Taken")
plt.title('Comparisons')
plt.show()
st("Hi")
st("We are Using python")
st("Have a Happy Coding!!")
Now is some glimpse of the Output Obtained:
From the Output of the Algorithm We came to know that there is linear growth of algorithm with time.
Have a Happy Coding!!