Solution Module Test FSD Merged 30th Oct-2
Solution Module Test FSD Merged 30th Oct-2
Round 1
1. . What are the different types of data types in JavaScript?
A) Primitive
B) Reference Type
C) All of the above
D) None of the above
Correct Ans: All of the above
1
SOLUTION FOR THE TEST
6. Any change in the variable inside the function will make a change in the value of the outside
variable. This is possible on passing variable to a function as:
A) Value
B) Reference
C) Name
D) None of these
Correct Ans: Reference
A) 20
B) 24
C) 1314
D) Undefined
Correct Ans: 24
9. Which of the following statement is true about JSON and JavaScript Objects?
A) Key should always be in double quotes in JSON
B) JSON and JS objects both resembles key-value pairs
C) Both a and b
D) None of the above
Correct Ans: Both a and b
2
SOLUTION FOR THE TEST
12. A linearly recursive function always has the recursive call at the ___ of the function.
A) Start
B) End
C) Either place
D) Some where in middle
Correct Ans: Either place
14. Recursive approach to find power of a number is preferred over iterative approach.
A) TRUE
B) FALSE
C) Not Sure
D) None of these
Correct Ans: FALSE
3
SOLUTION FOR THE TEST
19. Consider the following recursive implementation used to find the length of a string:
function recursive_get_len( s, len)
{
if(s[len] === undefined){
return 0;
}
return __________;
}
let s = "abcdef";
let len = recursive_get_len(s,0);
console.log(len)
Which of the following lines should be inserted to complete the above code?
A) 1
B) len
C) recursive_get_len(s, len+1)
D) 1 + recursive_get_len(s, len+1)
Correct Ans: 1 + recursive_get_len(s, len+1)
4
SOLUTION FOR THE TEST
20. Consider the following recursive implementation to find the sum of digits of number:
function recursive_sum_of_digits(n)
{
if(n == 0)
return 0;
return _________;
}
let n = 1201;
let ans = recursive_sum_of_digits(n);
console.log(ans)
Which of the following lines should be inserted to complete the above code?
A) (n / 10) + recursive_sum_of_digits(n % 10)
B) (n) + recursive_sum_of_digits(n % 10)
C) (n % 10) + recursive_sum_of_digits(Math.floor(n / 10))
D) (n % 10) + recursive_sum_of_digits(n % 10)
Correct Ans: (n % 10) + recursive_sum_of_digits(Math.floor(n / 10))
A) 10
B) 1
C) 10 9 8 7 6 5 4 3 2 1
D) 10 9 8 7 6 5 6 7 8 9 10
Correct Ans: 10 9 8 7 6 5 4 3 2 1
5
SOLUTION FOR THE TEST
6
SOLUTION FOR THE TEST
32. The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number
of iterations in selection sort and bubble sort respectively are __________
A) 5 and 4
B) 1 and 4
C) 0 and 4
D) 4 and 1
Correct Ans: 4 and 1
7
SOLUTION FOR THE TEST
33. How many queues are needed to implement a stack. Consider the situation where no other data
structure like arrays, linked list is available to you.
A) 1
B) 2
C) 3
D) 4
Correct Ans: 2
8
SOLUTION FOR THE TEST
39. What will be the space complexity of the program where we use an additional stack for storing n
elements?
A) O(nlogn)
B) O(n)
C) O(1)
D) O(logn)
Correct Ans: O(n)
40. In which of the following type of LinkedList, the next pointer is never null?
A) Singly LL
B) Doubly LL
C) Circular LL
D) None of the above
Correct Ans: Circular LL
Round 2
Problem-1:
Problem Statement
Six friends go on a trip and are looking for accommodation. After looking for hours, they find a hotel which offers two types of
rooms — double rooms and triple rooms. A double room costs Rs. XX, while a triple room costs Rs. YY.
The friends can either get three double rooms or get two triple rooms. Find the minimum amount they will have to pay to
accommodate all six of them.
Input Format
● The first line contains a single integer TT - the number of test cases. Then the test cases follow.
● The first and only line of each test case contains two integers XX and YY - the cost of a double room and the cost of a
triple room.
Output Format
For each testcase, output the minimum amount required to accommodate all the six friends.
9
SOLUTION FOR THE TEST
Constraints
● 1 ≤ T ≤ 1001≤T≤100
● 1 ≤ X <Y ≤ 1001≤X<Y≤100
Sample 1:
Input
3
10 15
68
48
Output
30
16
12
Sample 2:
Input
3
40 30
60 80
40 80
Output
60
160
120
Sample 3:
Input
4
80 90
38 50
50 80
100 150
10
SOLUTION FOR THE TEST
Output
180
100
150
300
Sample 4:
Input
5
750 900
348 530
500 840
1000 1500
2000 3000
Output
1800
1044
1500
3000
6000
Sample 5:
Input
7
7050 9900
3408 5030
5070 8490
10080 15090
20800 30900
7657 9798
7900 3434
11
SOLUTION FOR THE TEST
Output
19800
10060
15210
30180
61800
19596
6868
Explanation:
Test case 1: The friends can take three double rooms and thus pay a total of Rs. 30.
Test case 2: The friends can take two triple rooms and thus pay a total of Rs. 16.
Test case 3: The friends can take three double rooms and thus pay a total of Rs. 12.
Template:
const t = parseInt(readline());
function sixFriends () {
sixFriends();
12
SOLUTION FOR THE TEST
Solution:
const t = parseInt(readline());
function sixFriends () {
for (let i = 1; i<=t; i++) {
let [x, y] = readline().split(' ');
console.log(Math.min(2 * parseInt(y) , 3 * parseInt(x)));
}
}
sixFriends();
Problem-2:
Given an absolute path for a file as A. Return the string A as a simplified absolute path
Note:
Path is in Unix System format
In Unix-style file system:
Input Format
The only argument given is string A.
Output Format
Return a string denoting the simplified absolue path for a file (Unix-style).
13
SOLUTION FOR THE TEST
Samples 1:
Input:
A = "/home/"
Output:
"/home"
Samples 2:
Input:
A = "/a/./b/../../c/"
Output:
"/c"
Template
let simplifyPath = function(a){
const A = readline();
res = simplifyPath(A)
console.log(res)
Solution:
const A = readline();
res = simplifyPath(A)
console.log(res)
14
SOLUTION FOR THE TEST
Round 3
In this round you have to create a backend application for a librarian to manage books in a university.
Admin Functionality:
1. I should be able to log in
2. I should be able to Add Books
3. I should be able to Edit Books
4. I should be able to Delete Books
5. I should be able to get all book loan details
6. I should be able to approve loan request
7. I should be able to delete loan request
8. I should be able to get all the books
9. I should be able to send notification to user
User Functionality:
1. I should be able to sign up
2. I should be able to log in
3. I should be able to get my loan details
4. I should be able to create loan request for book
5. I should be able to get all the books
6. I should be able to get all the notification
7. I should be able to delete the notiication
Note:
1. Loan of book signifies lending of book of the user from admin
2. Please follow the proper folder structure as taught in class and maintain the code quality
Round 4
In this round, you have to create a frontend application for a librarian to manage books in a university.
Admin Functionality:
0. I should be able to log in
0. I should be able to Add Books
0. I should be able to Edit Books
0. I should be able to Delete Books
0. I should be able to get all book loan details
0. I should be able to approve loan request
0. I should be able to delete loan request
0. I should be able to get all the books
0. I should be able to send notification to user
15
SOLUTION FOR THE TEST
User Functionality:
0. I should be able to sign up
0. I should be able to log in
0. I should be able to get my loan details
0. I should be able to create loan request for book
0. I should be able to get all the books
0. I should be able to get all the notification
0. I should be able to delete the notiication
Note:
1. Loan of book signifies lending of book of the user from admin
2. Please follow the proper folder structure as taught in class.
Solution:
Please refer to the git repo for the sol of both Rounds 3 & 4:
https://github.com/singh-atul/Library_Management/tree/main/library_management
16