What Will Be The Worst Case Time Complexity For The Following #294
What will be the worst case time complexity for the following code?</p> <pre><code class="language-c"> #include <stdio.h> bool func(int arr[], int n, int sum) { if (sum == 0) return true; if (n == 0 && sum != 0) return false; if (arr[n-1] > sum) return func(arr, n-1, sum); return func(arr, n-1, sum) || func(arr, n-1, sum-arr[n-1]); } int main() { int arr[] = {4,6, 12, 2}; int sum = 12; int n = sizeof(arr)/sizeof(arr[0]); if (func(arr, n, sum) == true) printf("true"); else printf("false"); 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 Checksum Complexity Classes and NP-Complete Problems - Subset Sum Problem - 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