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); }}

Question

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); }}
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The time complexity of this function is O(n). This is because there is a single loop that runs n times. However, since the increment in each iteration is 98, the actual number of iterations is n/98. But in Big O notation, we ignore constants. So, the time complexity remains O(n). Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem. Knowee AI S

GPT 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 solve study problem.

This problem has been solved

Similar Questions

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 this function / algorithm?void f(int n){ printf("n = %d\n", n);}

What is the time complexity of this function / algorithm?void f(int n){ printf("n = %d\n", n);}O(n!)O(2^n)O(1)O(n)O(nlog(n))O(n^2)O(log(n))

What will you see on the terminal?int main(void){ int *ptr; *ptr = 98; printf("%d\n", *ptr); return (0);}

What will you see on the terminal?int main(void){ int *ptr; *ptr = 98; printf("%d\n", *ptr); return (0);}It doesn’t compileSegmentation Fault980

1/3