Vidyalelo
Data Structure · Q203

Dynamic Programming in Data Structures

Programming · Data Structure · question 203

Q203

What is the output of the following program? #include int longest_inc_sub(int *arr, int len) int i, j, tmp_max; int LIS[len]; // array to store the lengths of the longest increasing subsequence LIS[0]=1; for(i = 1; i tmp_max) tmp_max = LIS[j]; LIS[i] = tmp_max + 1; int max = LIS[0]; for(i = 0; i max) max = LIS[i]; return max; int main() int arr[] = 10,22,9,33,21,50,41,60,80, len = 9; int ans = longest_inc_sub(arr, len); printf("%d",ans); return 0;

A.
3
B.
4
C.
5
D.
6
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board