U.G.C. NET Exam. December 2022 Paper-II (COMPUTER SCIENCE) and Applicatations.

Total Questions: 100

91. Which of the following queries would retrieve the roll number and names of students who have enrolled for all the prerequisite course of the course number 324?

Correct Answer: (c) Select s.rollno, s.name From student s Where NOT EXISTS (select * prerequisite p where p.courseid = "324") and NOT EXISTS (select * from enrollment e where e.courseid = p.precoursied and e.rollno = s.rollno.)
Solution:

The correct query to retrieve the roll number and name of students who have enrolled for all the prerequisite courses of the course number 324.
C. Select s.rollno, s.name from student s Where NOT EXISTS (select * prerequisite p where p.courseid = "324") and NOT EXISTS (select * from enrollment e where e.courseid = p.precoursied and e.rollno = s.rollno.)

92. Given query : select s.rollno from students where s.sex = ALL (select f.sex from professor f where f.empid = s.advisor)

Consider the following statements about the given query that retrieves the set of all students whose gender is same as the gender of their advisor:
S1. It has a correlated subquery
S2. It has an uncorrelated subquery
S3. If we replace ALL by ANY in the above query, its result will be different.
S4. If we replace ALL by ANY in the above query, its result will be same.
Identify all the statement that are TRUE :

Correct Answer: (b) S1 and S4 are true
Solution:

The correct query to retrieves the set of all students whose gender is same as the gender of their advisor :
S1. It has a correlated subquery
S4. If we replace ALL by ANY in the above query, its result will be same.
So option (b) is correct.

93. Which of the following queries would compute, for each department, the total credits of all the courses offered by the department?

Correct Answer: (a) select deptid, name, sum(credits) as totalcredits from department, course where deptid = deptno group by deptid, name;
Solution:

The correct query to compute for each department, the total credits of all the courses offered by the department -
Select deptid, name, sum(credits) as totalcredits from department, course where deptid = deptno.

94. Which of the following queries would retrieve the dept id and name of the all departments that are such that the total of the credits of all the offered courses by the department is strictly greater than 40?

Correct Answer: (d) Select deptid, name, sum(credits) as totalcredits from department, course where deptid = deptno group by deptid, name having totalcredits > 40
Solution:

The correct queries to retrieve the dept id and name of the all departments that are such that the total of the credits of all the offered courses by the department is strictly greater than 40. Select deptid, name, sum(credits) as totalcredits from department, course where deptid = deptno group by deptid, name having totalcredits > 40

95. Given query :

select s.rollno, s.name from student s where EXISTS (select c.courseid from course c Where c.deptno = 5 and EXISTS (select e.* from enrollment e where e.courseid = c.courseid and e.rollno = s.rollno)));
Which one of the following statement is correct with respect to the given query?

Correct Answer: (c) It retrieves the roll number and names of students who have enrolled for at least one course offered by department number 5.
Solution:

96. For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}
Find the optimal solution for fractional knapsack problem when its maximum capacity is 15.

Correct Answer: (b) 40
Solution:

97. For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}
What is the maximum value of items you can carry if maximum weight allowed is 25 with a fractional knapsack?

Correct Answer: (a) 48.1
Solution:

98. For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}
If new item (P=5, W=2) is added to the list, total items is 8 and capacity is 25, then the bestcase time of fractional knapsack for this case is_____

Correct Answer: (c) O(24)
Solution:

99. For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}
The most efficient solution for the fractional knapsack problem with maximum capacity 15 can be obtained by using ______

Correct Answer: (c) Greedy Algorithm
Solution:

A knapsack problem, P and W are profits and weights for a set of 7 items as given below:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}
The most efficient solution for the fractional knapsack problem with maximum capacity 15 can be obtained by using Greedy Algorithm.
So option (c) is correct.

100. For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}
Which of the following statements is correct for a knapsack?

Correct Answer: (d) In 0/1 knapsack problem, items cannot be divided into smaller portions and in fractional knapsack we can divide the item into required proportions of weight.
Solution: