Consider the following algorithm for finding the nth Catalan number using dynamic approach. which of the following steps best fills the blank?
1) create and initialize a variable 'n' and an array 'c'
2) initialize the first two values of array as 1
3) _______________________
4) return c[n]
A. Traverse the array from 2 to n one by one and update the value as c[j] * c[i-j-1]
B. Traverse the array from 2 to n one by one and update the value as c[i] * c[i-j-1]
C. Traverse the array from 2 to n one by one and update the value as c[j] * c[i-1]
D. Traverse the array from 2 to n one by one and update the value as c[i] * c[j-1]
Answer: Option A
Related Questions on Miscellaneous on Data Structures
Which data structure is used to implement a binary heap efficiently?
A. Array
B. Linked List
C. Stack
D. Queue
In which scenario would you use a Bloom Filter?
A. For implementing a stack-based algorithm
B. To maintain a balanced binary tree
C. For efficient sorting of elements
D. To test membership in a large dataset
A. Queue
B. Stack
C. Heap
D. Array

Join The Discussion