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

Assignment - Docx Lodhi

Uploaded by

arlodhi67
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)
12 views1 page

Assignment - Docx Lodhi

Uploaded by

arlodhi67
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
You are on page 1/ 1

Assignment:No:1

Student:ID: bc240424128

Subject:cs502
Question:No:1

Answer:

Int n = arr.size(); O(1)

//First loop:print each element of the array


For(int i = 0;j < n; ++i) { O(n)
std::cout << arr[i] < < std::end]; O(n)
}

// Second nested loop: print the product of each triplet of elements


for (int j = 0; j < n; ++j) { O(n3)
for (int k = 0; k < n; ++k) { O(n3)
for (int 1= 0;1 < n; ++1) { O(n3)
std::cout << arr[j] * arr[k] * arr[1] << std::end1; O(n3)
}
}
}

The overall time complexity of the given code is


O(n3)

You might also like