logo

Crowdly

What will be the best case time complexity of the following code? #include<bi...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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;

}

0%
0%
0%
100%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moovit.vit.ac.in?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!