Questions 121–130 of 975. Imported answers require independent review unless marked reviewed.

Topic practice 975 questionsPage 13 of 98

Question 61

Open question
CSNAT2 marksNeeds review
Consider the recursive functions represented by the following code segment:
int bar(int n){
if (n == 1) return 0;
else return 1 + bar(n/2);
}

int foo(int n){
if (n == 1) return 1;
else return 1 + foo(bar(n));
}
The smallest positive integer

for which foo(n) returns 5 is _____. (answer in integer)
Note: Ignore syntax errors (if any) in the function.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 61

Open question
CS2NAT2 marksNeeds review
Consider the following ANSI-C function.
int func(int start, int end){
int length=end+1-start;
if((length<1)||(start<0)||(end<0)){ return(0); }
if(length%3==0){
return(func(start+1, end));
} else if(length%3==1){
return(1+func(start, end-1));
} else {
return(func(start+2, end));
}
}
The maximum possible value that can be returned from this function is __________. (answer in integer)
Note: Ignore syntax errors (if any) in the function.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 62

Open question
CSNAT2 marksNeeds review
The following sequence corresponds to the preorder traversal of a binary search tree

:
50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77
The position of the element 60 in the postorder traversal of

is _____. (answer in integer)
Note: The position begins with 1.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 62

Open question
CS2NAT2 marksNeeds review
The determinant of a 4 × 4 matrix A is 3. The value of the determinant of 2A is __________. (answer in integer)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 63

Open question
CSNAT2 marksNeeds review
Consider the following program snippet. Assume that the program compiles and runs successfully. Further, assume that the fork() system call is always successful in creating a process.
int main () {
int i;
for (i = 0; i < 3; i++){
if (fork() == 0)
continue;
break;
}
printf("Hello!");
return 0;
}
The total number of times that the printf statement gets executed is ________. (answer in integer)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 63

Open question
CS2NAT2 marksNeeds review
Suppose an unbiased coin is tossed 6 times. Each coin toss is independent of all previous coin tosses. Let E_1 be the event that among the second, fourth, and sixth coin tosses, there are at least two heads. Let E_2 be the event that among the first, second, third, and fifth coin tosses, there are equal number of heads and tails.
The conditional probability P(E_1|E_2) is equal to __________. (rounded off to one decimal place)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 64

Open question
CSNAT2 marksNeeds review
Consider a CPU that has to execute two types of processes. The first type, Actuators (A), requires a CPU burst of 6 seconds. The second type, Controllers (C), requires a CPU burst of 8 seconds. A new process of type A arrives at time

and

(in seconds). Similarly, a new process of type C arrives at time

and

(in seconds). The CPU scheduling policy is First Come First Serve (FCFS). The first process of type A starts running at

seconds. The average waiting time (in seconds) for the 10 processes is __________. (rounded off to one decimal place)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 64

Open question
CS2NAT2 marksNeeds review
Consider a function

defined as follows.
For a real number

,

if the second digit after the decimal point in

is one of the four digits 2, 3, 6 and 7. Otherwise,

is equal to 0.
The number of points in (0,1) at which

is discontinuous is __________. (answer in integer)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 65

Open question
CSNAT2 marksNeeds review
Consider a relational database schema with a relation

. If

and

are the only two candidate keys of the relation

, then the number of superkeys of relation

is _____. (answer in integer)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 65

Open question
CS2NAT2 marksNeeds review
It is necessary to design a link-layer protocol between two hosts that are directly connected over a lossless link of length 300 kilometers. Assume that the link bandwidth is

bits per second and that the propagation delay in the link is 5 nanoseconds per meter. Every transmitted data byte is assigned a unique sequence number.
Let

be the minimum number of bits needed for the sequence number field in the protocol header such that
i. the sequence numbers do not wrap around before 60 seconds, and ii. the maximum utilization of the link is achieved.
The value of

is ______. (answer in integer)

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer