My Report

Data Structure II Mock Test 7


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. In dynamic programming, the technique of storing the previously calculated values is called ___________

Question 1 of 10

Question 2 of 10

2. Given items as {value,weight} pairs {{60,20},{50,25},{20,5}}. The capacity of knapsack=40. Find the maximum value output assuming items to be divisible and nondivisible respectively.

Question 2 of 10

Question 3 of 10

3. What will be the recurrence relation of the code of recursive selection sort?

Question 3 of 10

Question 4 of 10

4. Suppose you are given infinite coins of N denominations v1, v2, v3,.....,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. What is the space complexity of a dynamic programming implementation used to solve the coin change problem?

Question 4 of 10

Question 5 of 10

5. Which of the following correctly implements iterative code for finding power of a number?

Question 5 of 10

Question 6 of 10

6. Consider the following code snippet to find the smallest element in a linked list:

struct Node
{
     int val;
     struct Node* next;
}*head;
int get_min()
{
      struct Node* temp = head->next;
	  int min_num = temp->val;
	  while(temp != 0)
	  {
	       if(_________)
		    min_num = temp->val;
		temp = temp->next;
	  }
	  return min_num;
}

Which of the following lines should be inserted to complete the above code?

Question 6 of 10

Question 7 of 10

7. Fractional knapsack problem is solved most efficiently by which of the following algorithm?

Question 7 of 10

Question 8 of 10

8. Consider the following recursive implementation of linear search:

#include<stdio.h>
int recursive_search_num(int *arr, int num, int idx, int len)
{
     if(idx == len)
     return -1;
     if(arr[idx] == num)
       return idx;
     return __________;
}
int main()
{
      int arr[5] ={1,3,3,3,5},num=2,len = 5;
      int indx = recursive_search_num(arr,num,0,len);
      printf("Index of %d is %d",num,indx);
      return 0;
}

Which of the following recursive calls should be added to complete the above code?

Question 8 of 10

Question 9 of 10

9. Solve the following recurrence using Master’s theorem.
T(n) = 4T (n/2) + n2

Question 9 of 10

Question 10 of 10

10. What is the objective of the knapsack problem?

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.