What is the time complexity of the following code segment in big O notation? for (int i=0; i
What is the time complexity of the following code segment in big O notation? for (int i=0; i
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
What is the time complexity of the following code segment in big O notation?
for (int i=0; i<n; i++) {
for (int k=0; k<n; k++) {
if (k < 5)
cout << 5*i*k ;
else
cout <<i*k;
}
cout << endl;
}
Question 17 options:
|
O(n3) |
|
O(n2) |
|
O(nlogn) |
|
O(n) |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps