Computer Science EngineeringVery hardISRO SC (CS)
Fractional knapsack: weights [10, 4, 12, 3], values [20, 40, 14, 35], capacity 18. The maximum total value (rounded to the nearest integer) is:
- A. 98
- B. 96
- C. 99
- D. 93
Correct answer: B. 96
Sort by value/weight, take whole items then a fraction of the next: 96.17. (Greedy by raw value gives 96.17.)
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- Consider the following C fragment. int c=0; int x=100; while(x>0){ for(int j=0;j<x;j++) c++; x/=3; } What is c at the end? (integer…
- The number of distinct permutations of 1..7 that can be produced as output by pushing 1,2,...,7 in order onto a stack and popping at any…
- How many structurally distinct binary trees (left and right children distinguished) with exactly 6 nodes have height exactly 4 edges?
- Using the Master theorem (extended form), the solution of T(n) = 2T(n/4) + n is:
- The keys [10, 14, 40, 49, 41, 19, 38] are inserted in this order into an initially empty AVL tree. Its preorder traversal is:
- A connected simple undirected graph has 8 vertices and 12 edges. The minimum number of edges that must be removed to obtain a spanning…