Select the correct option to test your answer:
Computer
Dynamic Programming In Data Structures
Difficulty: Medium
What is the time complexity of the following dynamic programming algorithm used to find the maximum sub-array sum? #include<stdio.h> int max_num(int a,int b) { if(a> b) return a; return b; } int maximum_subarray_sum(int *arr, int len) { int sum[len], idx; sum[0] = arr[0]; for(idx = 1; idx < len; idx++) sum[idx] = max_num(sum[idx - 1] + arr[idx], arr[idx]); int mx = sum[0]; for(idx = 0; idx < len; idx++) if(sum[idx] > mx) mx =sum[idx]; return mx; } int main() { int arr[] = {-2, -5, 6, -2, 3, -1, 0,-5, 6}, len = 9; int ans = maximum_subarray_sum(arr, len); printf("%d",ans); return 0; }
More Computer Questions
The term___________designates equipment that might be added to a computer system to enhance its functionality.
The first page of document is ___________?
Which SQL phrase is not supported by Oracle?
What will be the output of the following C# code? using System; public class BaseClass { public BaseClass() { Console.WriteLine("I am a base class"); } } public class ChildClass : BaseClass { public ChildClass() { Console.WriteLine ("I am a child class"); } static void Main() { ChildClass CC = new ChildClass(); } }
Which of these interface extends DataInput interface?