Vidyalelo
Data Structure · Q1062

Miscellaneous on Data Structures

Programming · Data Structure · question 1062

Q1062

What is the approach implemented in the following code? #include using namespace std; void printArray(int p[], int n) for (int i = 0; i = 0 && p[k] == 1) rem_val += p[k]; k--; if (k p[k]) p[k+1] = p[k]; rem_val = rem_val - p[k]; k++; p[k+1] = rem_val; k++; int main() int n; cin>>n; func1(n); return 0;

A.
greedy approach
B.
dynamic programming
Answer
C.
recursion(divide and conquer)
D.
backtracking

Answer: Option B

Solution

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