Question #225267

Briefly answer the following short questions

1) Determine if the following argument is valid and explain why. Every CS

major takes CMSC203. Mr. Ali is taking CMSC203, therefore he is a CS

major.

2) What is the time complexity (in Big-O notation) of the following code? Your

answer should be a function of n. Also, what is the value of “sum” after the

execution of the code with n = 10?

sum := 0;

for i := 1 to n

for j := i to n

sum := sum + 1

Expert's answer

1)

Invalid: p →\to q and q do not support the conclusion of p


2)

Algorithm makes

n(n−1)...1=n!n(n-1)...1=n! operations

so,

f(n)=O(n!)f(n)=O(n!)


for n = 10:

sum=10+9+8+...+2+1=55sum=10+9+8+...+2+1=55


LATEST TUTORIALS
APPROVED BY CLIENTS