(b) Suppose T(1) represents the number of times the function prints when called
ID: 3606693 • Letter: #
Question
(b) Suppose T(1) represents the number of times the function prints when called with an argument 1, T(2) represents the number of times the function prints when called with an argument 2, ..., T(n - 1) represents the number of times the function prints when called with an argument n - 1, and T(n) represents the number of times the function prints when called with an argument n. We can now make the following argument: func (n) will print once (it prints the number n) and will follow this up by calling func (n-1),n times. According to our notation, each such call prints T(n-1) times. Therefore T(n)=1+nT(n-1). Based on this information, does the program run in polynomial time? Provide an explanation for your answer.Explanation / Answer
in big o notation
set i=0 //1
while(i<n) //n comparisons
set j=0 //n assignment
while(j<n) //n*n comparisons
display(a[i][j]) //n*n writes
increment j by 1 //n*n increments
increment i by 1 //n increments
as u count no of comparison (n2+n)
since in your program there is no comparison
hence it is not polymorphysm
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.