Home / MCQ Bank / Computer
Computer Searching Algorithms Difficulty: Medium

What will be the best case time complexity of the following code? #include<bits/stdc++.h> using namespace std; void func(char* str2, char* str1) { int m = strlen(str2); int n = strlen(str1); for (int i = 0; i <= n - m; i++) { int j; for (j = 0; j < m; j++) if (str1[i + j] != str2[j]) break; if (j == m) cout << i << endl; } } int main() { char str1[] = "1253234"; char str2[] = "323"; func(str2, str1); return 0; }

Select the correct option to test your answer:

More Computer Questions

Which of the following concept is best to preventing page faults? Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements? Which of these class is not a member class of java.io package? You type show running-config and get this output: [output cut] Line console 0 Exec-timeout 1 35 Password BIXPASSWD Login [output cut] What do the two numbers following the exec-timeout command mean? Consider the following code snippet function printprops ( o ) { for(var p in o ) console . log ( p + ": " + o [ p ] + "n" ) ; } What will the above code snippet result ?