What Will Be The Worst Case Time Complexity Of The Following #538
What will be the worst case time complexity of the following code?</p> <pre><code class="language-c"> #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; } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Searching - Substring Searching Algorithm - Quiz No.1.
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes