Choose the correct time complexity expression of the following pseudocode : START : i , count = 0 ;while ( count < n ) i = i + 1 ; count = count + i ;
Question
Solution 1
The time complexity of the given pseudocode is O(sqrt(n)).
Here's the step-by-step explanation:
- The loop runs until the variable 'count' is less than 'n'.
- In each iteration, 'i' is incremented by 1 and 'count' is incremented by 'i'.
- This means that 'count' increases by 1, then 2, then 3, Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv
Similar Questions
Choose the correct time complexity expression of the following pseudocode : START : i , count = 0 ;while ( count < n ) i = i + 1 ; count = count + i ;
What is the time complexity of the following code : int a = 0, i = N; while (i > 0) { a += i; i /= 2; }
The time complexity of the following code snippet isc=0; while (n>=1) {for(i=1;i>=n;i++){ c++;}n=n/2;}
What is the time complexity of this function / algorithm?void f(int n){ int i; for (i = 0; i < n; i += 98) { printf("[%d]\n", i); }}
What is the time complexity of the following code fragment?for(i=1; i<n; i= i*2) a[i]=0;