What Will Be The Time Complexity Of The Following Codep Pre #389
What will be the time complexity of the following code?</p> <pre><code class="language-c"> #include <bits/stdc++.h> using namespace std; void func1(int arr[], int n) { int k = arr[0], i; for (i = 0; i < n - 1; i++) arr[i] = arr[i + 1]; arr[i] = k; } void func(int arr[], int d, int n) { for (int i = 0; i < d; i++) func1(arr, n); } void printArray(int arr[], int n) { for (int i = 0; i < n; i++) cout << arr[i] << " "; } int main() { int arr[] = { 1, 2, 3, 4, 5}; int n = sizeof(arr) / sizeof(arr[0]); int d = 3; func(arr, d, n); printArray(arr, n); return 0; } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Array Types - Rotation Array Operation - Quiz No.1.
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes