HPSC Assistant Professor Computer Science Question Paper 2019 Solution

Year: 2019 Session: Morning Paper Code: 702

Ques 1: MS JK Flip Flop is equivalent to:
(A) JK Flip Flop
(B) SR Flip Flop
(C) Negative Edge Triggered Flip Flop
(D) Positive Edge Triggered Flip Flop

Ans : (C) Negative Edge Triggered Flip Flop

Ques 2: How many 3 to 8 line decoders with an enable input are needed to construct a 6 to 64 line decoder without using any other logic gates?
(A) 7
(B) 8
(C) 9
(D) 10

Ans: (C) 9

Ques 3: Which of the following logic operations is performed by the following combinational circuit:
(A) Exclusive-OR
(B) Exclusive-NOR
(C) NAND
(D) NOR

Ans: (A) Exclusive-OR

Ques4: In the following truth table, V=1 if and only if the input is valid:

Input 1Input 2Input 3Input 4Output 1 Output 2Output 3
D0D1D2D3X0X1V
0000xx0
1000001
x100011
xx10101
xxx1111

What function does the truth table represent?
(A) Priority Encoder
(B) Decoder
(C) Multiplexer
(D) Demultiplexer

Ans: (A) Priority Encoder

Ques 5: When two n-bit binary numbers are added, the sum will contain at the most:
(A) n bits
(B) (n+3) bits
(C) (n+2) bits
(D) (n+1) bits

Ans: (D) (n+1) bits
Solution: Max of two digits at nth place for two binary numbers i.e. 1 + 1 along with max carry i.e. 1 will produce Sum of n bits along with carry as 1 i.e. total n+1 bits
Example 1111 (4 bits) + 1111 (4 bits) = 11110 (5 bits)

Ques 6: The complement of the function F=(A+B’)(C’+D)(B’+C) is:
(A) A’B + CD’+ BC’
(B) AB’+C’D+B’C
(C) AB’+CD’+BC
(D) AB+BC+CD

Ans: (A) A’B + CD’+ BC’
Solution: ((A+B’)(C’+D)(B’+C))’
=(A+B’)’ + (C’+D)’ + (B’+C)’
=A’B+CD’ + BC’

Ques 7:Consider the hypothetical CPU with three register R1, R2 and R3 and following program is executing on the CPU:

InstructionOperationInstruction Size in words
ADD R1,R2,R3R1<–R2 + R33
MOV R3,1000R3<– Memory 10002
SUB R2,R3r2<–R2-R31
MOV 6000, R2Memory[6000]<–R23
HALTMachine Halt1

Assume that the memory is byte addressable with word size 32 bits and program is loaded with memory location 2000 (decimal) onwards. If an interrupt occurs, CPU is halted after executing HALT instruction and the return address (in decimal) saved in the stack will be:
(A) 2035
(B) 2019
(C) 2039
(D) 2040

Ans: (D) 2040

Ques 8: Consider a control unit generating the control signals, which are divided into 5 mutually exclusive groups as shown below:

GroupsG1G2G3G4G5
Control Signal3710122

How many bits are saved using the vertical Micro Programmed instead of Horizontal Micro Programmed Control Unit?
(A) 14
(B) 34
(C) 20
(D) None

Ans: (C) 20

Ques 9: Consider a memory organisation having 4-way set associative cache memory unit with size of 32KB is built by using a block of size 16 words. The word length is 32 bits. The size of physical address is 4 GB. Calculate the tag field bit in physical address.
(A) 16
(B) 18
(C) 20
(D) 14

Ans: (B) 18

Ques 10: Consider the multi level cache memory with 3 level caches. Access time of level L1, L2, L3 and main memory are 5ns, 20ns, 100ns, 500ns respectively. The hit rates of Level L1, L2 and L3 are 0.75, 0.80 and 0.90 respectively. What is the average access time of the system ignoring the search time within the cache?
(A) 13.25 ns
(B) 12.50 ns
(C) 14.75 ns
(D) 15 ns

Ans:(C) 14.75 ns
Solution: First It will search L1
Time to search L1=5ns * 0.75= 3.75
If not found in L1 i.e 25% time , Search in L2
Time to search L2= 0.25 *20*0.80 = 4 ns
If not found in L1 (i.e 25% time) and L2 (i.e 20 % time) , Search in L3
Time to search L3= 0.25 * 0.20 * 0.90 * 100 = 4.5ns
If not found in L1 (i.e 25% time) and L2 (i.e 20 % time) and L3( 10% time) Search in memory
Time to search in memory = 0.25* 0.20 * 0.10 * 500= 2.5
Adding all these gives 14.75ns

Ques 11: What will be the output of the following program:

#include<stdio.h>
void main()
{
int cnt=1;
do
{
printf("%d",cnt);
cnt+=1;
}
while(cnt>=10);
printf("\nAfter loop cnt=%d",cnt);
printf("\n");
}

(A) 1After loop cnt=11
(B) 1After loop cnt=1
(C) 1After loop cnt=2
(D) 1After loop cnt=10

Ans: (C) 1After loop cnt=2
Solution: Initially cnt=1
It entered into the loop, printed the value of cnt i.e 1
and incremented the value of cnt by 1 i.e cnt is now 2
Now the condition will be checked cnt>=10 but 2>=10 is false
So it will come out of the loop and print the value of cnt i.e. 2
After loop cnt=2
So finally 1After the loop cnt=2
will be the output

Ques 12: What will be the output of the following program:

#include<stdio.h>
void main()
{
int arr[5];
//suppose base address of array is 102
arr++;
printf("%u",arr);
}

(A) 102
(B) 104
(C) 106
(D) L Value required

Ans: L Value required

Ques 13: What will be the output of following program?

#include<stdio.h>
void disp(int arr[])
{
int n=sizeof(arr)/sizeof(arr[0]);
int i;
    for( i=0;i<n;i++)
    printf("%d,"arr[i]);
}
void main()
{
int arr[]={1,2,3,4,5,6,7,8};
disp(arr);    
}

(A) 1,2,3,4,5,6,7,8
(B) 1
(C) 1,
(D) Compile Time Error

Ans: (D) Compile Time Error
Solution: Read the line having printf() carefully

Ques14: What will be the output of following program?

#include<stdio.h>
int show(char * ctr1)
{
char * ctr2=ctr1;
while(* ++ctr1);
return(ctr1-ctr2);
}
void main()
{
char *ctr1="ExampleOfString";
printf("%d",fun(ctr1);
}

(A) 15
(B) 14
(C) 1
(D) None of the above
Ans: (D) None of the above

Solution: Read the question carefully. fun() is called
but no function with name fun() is defined
show() function is defined here
If at both places , function name were same, answer would be (A) 15
Initially when function was called, both ctr1 and ctr2 will point to ‘E’
in the while loop, ctr1 will move upto 1 position beyond string end and then come out of loop.
ctr1 will now point to 15 bytes beyond base address
ctr1-ctr2=(Base address + 15 bytes) -(Base Address)=15

Ques 15: What is the use of rewind function in C?
(A) Set the position to the begining point
(B) gives current position in the file
(C) set the position to desired point
(D) None of these

Ans: (A) Set the position to the begining point

Ques 16: If student is the name of class, select correct answer for declaring copy constructor of same class:
(A) student( student param)
(B) student(student * param)
(C) student(const student * param)
(D) student(const student & param)

Ans: (D) student(const student & param)

Ques 17: Which member of the given class will occupy space in memory for object obj1?

class example
{
int num1;
static int num2;
static void show() {  }
void disp() { }
}obj1;

(A) int num1;
(B) static int num2;
(C) static void show() { }
(D) void disp() { }

Ans: (A) int num1;
Solution : Static variables are just like global variables of that class and dnt reserve space for every object.

Ques 18: What is the type of “this” pointer if the name of class is hello?
(A) const hello * const;
(B) hello * const
(C) hello *
(D) hello &

Ans: (B) hello * const

Ques 19: What will be the output of following code?

class Example
{
public: static int num1=10;
};
void main()
{
cout<<Example::I;
}

(A) 10
(B) 0
(C) Compile time error
(D) Run time error

Ans: (C) Compile time error

Ques 20: What will be the output of following program?

#include<iostream.h>
void fun(int & p)
{
int t=1;
while(t<=5)
{
p=p+t;
t++;
}
cout<<"p="<<p;
}
void main()
{
int num1=4;
fun(num1);
cout<<"num1="<<num1;
}

(A) p=9num1=9
(B) p=9num1=4
(C) p=19num1=19
(D) p=19num1=4

Ans: (C) p=19num1=91

Ques 21: Given the following relation instance with only 4 records:

Roll_NoSubjectMarks
1001Math65
1001English75
1001Hindi75
1002Biology65

Which of the following functional dependencies are satisfied by the instance?
(A) (Roll_No,Subject)->Marks and Marks->Subject
(B) (Subject, Marks)->Roll_no and Rollno->Marks
(C) (Subject, Marks)->Roll_no and Subject->Marks
(D) (Roll_No, Marks)->Subject and Subject->Roll_No

Ans: (C) (Subject, Marks)->Roll_no and Subject->Marks
Solution: Clearly from the table, Subject is unique and subject alone can’t determine Roll_No but it can determine marks
Also, Subject and Roll_No cant give unique marks (See the first two rows)
But Subject and marks can find unique rollno
So (Subject,Marks)->Roll_No

Ques 22:Consider the following two statements about database transaction schedules:
I. Strict two phase locking protocol generates conflict serializable schedules that are not recoverable.
II. Time stamp ordering concurrency control protocol with Thomas Write Rule can generate view serializable schedules that are not conflict serializable.
Which of the above statements is/are True?
(A) Both I and II
(B) Neither I nor II
(C) Only II
(D) Only I

Ans: (C) Only II

Ques 23: A relational database contains two tables Student and Performance as shown below:

Student

Roll_NoName
1001Anu
1002Amita
1003Sunita
1004RajKishore
1005Nand Kumar

Performance

Roll_NoSub_CodeMarks
1001MA 10175
1001MA 10367
1002MA 10158
1002MA 10387
1002MA 10579
1003MA 10354

The primary key of the student table is Roll_No. For the performance table, the columns Roll_No and Sub_Code together form the primary key. Consider the SQL Query given below.
Select S.name, Sum(P.marks) from student S, performance P where S.Roll_no=P.Roll_No and P.marks>74 group by S.student_Name
The number of rows returned by the above SQL Query is:
(A) 0
(B) 2
(C) 6
(D) 5

Ans: (B) 2
Solution: Basically first it will consider only 3 rows from Performance table containing Marks>74
Then it will check another condition i.e. S.Roll_no=P.Roll_No and
the cartesian product will return 3 rows having P.Roll_No as 1001, 1002, 1002
Then it will combine two rows due to group_by clause on S.name

Ques 24: In a ER Model, suppose R is a many to one relationship from entity set E1 to entity set E2. Assume that E1 and E2 participate totally in R and the cardinality of E1 is greater than the cardinality of E2.
Which one of the following is true about R?
(A) every Entity in E1 is associated with exactly one entity in E2
(B) Some Entity in E1 is associated with more than one entity in E2
(C) every Entity in E2 is associated with exactly one entity in E1
(D) Every Entity in E2 is associated with at most one entity in E1

Ans: (A) every Entity in E1 is associated with exactly one entity in E2
Clearly E1->E2 is m:1

Ques 25: Given relations A(a,b) and B(c,d), the result of
Select distinct a,b from A,B
is guaranteed to be same as A, provided:
(A) A & B have no duplicates
(B) B has no duplicates and A is non empty
(C) A has no duplicates and B is non empty
(D) A and b have the same number of tuples.

Ans: (C) A has no duplicates and B is non empty
Clearly it will return A as we have not displayed any column i.e c or d from table B
Since we have used distinct clause, it will remove duplicate rows from table A
ie. It will return the same table A only if A has no duplicates

Ques 26: A relation R ={A,B,C,D,E,F,G} is given with following set of functional dependencies:
F={AD->E, BE->F, B->C, AF->G}
Which of the following is a candidate key:
(A) BE
(B) AB
(C) ABD
(D) ABC

Ans: (C) ABD
Solution: Since A, B, D cant be determined by any other key (bcoz these are not available on Right hand Side of any Functional
ependencies) ,
So they may be a part of candidate key
Now candidate key is the set of minimal fields that can uniquely determine a relation.
Possible Combinations from ABD are
A-> No field
D->No Field
B->C only
AB->C Only
BD->C Only
AD->E Only
ABD->C,E, F, G
But only ABD is capable of uniquely determining all the fields

Ques 27: For a database relation R(A,B,C,D) where the domains of A,B,C,D include only atomic values, only the following functional dependencies and those that can be inferred from them hold:
A->B
C->D
The relation R is
(A) in 1 NF but not in 2NF
(B) in 2NF but not in 3NF
(C) in 3NF
(D) None of the above

Ans: (A) in 1 NF but not in 2 NF
Solution: Candidate Key of above relation is :- AC only.
A and C is partial attribute (part of the Candidate Key) that’s why the given FD is partially dependents.
In 2NF there must not be partially dependents FD and we know that every table is already in 1NF.
Hence, this relation is in first normal form but not in second normal form.
Option (A) is correct.

Ques 28: In case of Distributed Database Systems, which of the following is true concerning a global transcation?
(A) The required data are at one local site and the distributed DBMS routes requests as necessary.
(B) The required data are located in at least one nonlocal site and the distributed DBMS routes requests as necessary.
(C) The required data are at one local site and the distributed DBMS passes the request to only the local DBMS
(D) The required data are located at least one non local site and the distributed DBMS passes the request to only the local DBMS

Ans: (B) The required data are located in at least one nonlocal site and the distributed DBMS routes requests as necessary.

Ques 29: A semi join is which one of the following?
(A) Only the joining attributes are sent from one site to another and then only the required rows are returned.
(B) Only the joining attributes are sent from one site to another and then all of the rows are returned.
(C) All the attributes are sent from one site to another and then only the required rows are returned.
(D) All the attributes are sent from one site to another and then all of the rows are returned.

Ans: (A) Only the joining attributes are sent from one site to another and then only the required rows are returned.

Ques 30: In Object Oriented Database System, an extent is which of the following?
(A) A keyword that indicates that the subclass inherits from a superclass
(B) A keyword that indicates that the superclass inherits from a subclass
(C) The set of all instances of a class within a databse
(D) Only 1 instance of a class within a database

Ans: (C) The set of all instances of a class within a database

Ques 31: Let G be a connected graph with |G| >=2 and let v be a vertex in G. If G\{v} is connected then,
(A) deg(v)=1
(B) v is on a cycle
(C) either deg(v)=1 or v is on a cycle
(D) both deg(v)=1 and v is on a cycle

Ans: (C)either deg(v)=1 or v is on a cycle

Ques 32: An undirected graph G with n vertices and e edges is represented by adjacency list. What is the time required to generate all the connected componensts.
(A) O(n)
(B) O(e)
(C) O(n+e)
(D) O(e2)

Ans: (C) O(n+e)

Ques 33: Let A, B and C are 3 sets and f:A->B, g: B->C and the composition of g and f, gof: A->C. Then gof is injective if
(A) f is injective
(B) g is injective
(C) Both f and g are injective
(D) f is injective and g is surjective

Ans: (C) Both f and g are injective
injective or one-one function means having only a unique image for every element
In gof:A->C, image of A ->C will be unique only if A->B and B->C both are unique i.e f and g both are one-one

Ques34: What is the hash function used in hashing?
(A) h1(K) + h2(K)
(B) (h1(k) – i*h2(k)) mod m
(C) (h1(K) + h2(K) ) mod m
(D) (h1(k) + i *h2(k)) mod m

Ans : (D) (h1(k) + i *h2(k)) mod m

Ques 35: Given an array of elements 5,7,9,1,3,10,8,4. Which of the following is the correct sequences of elements after inserting all the elements in a min heap?
(A) 1,4,3,9,8,5,7,10
(B) 1,3,4,5,7,8,9,10
(C) 1,3,4,5,8,7,9,10
(D) 1,3,7,4,8,5,9,10

Ans: (B) 1,3,4,5,7,8,9,10

Ques 36: Counting Sort performs —————————-number of comparisons between n input elements.
(A) 0
(B) n
(C) n log n
(D) n2

Ans: (A) 0
Solution: Counting sort don’t compare elements. rather it just places an element on its specified index only.

Ques 37: What is the auxiliary space complexity of standard merge sort?
(A) O(1)
(B) O(log n)
(C) O(n)
(D) O(n log n)

Ans: (C) O(n)
Solution: Here Space complexity is asked, not the time complexity.
and, Extra space is needed to store every element.
So Space Complexity is O(n)

Ques: 38: When a top down approach of dynamic programming is applied to a problem, it usually
(A) Decreases both, time complexity and space complexity.
(B) Increases time complexity but decreases space complexity.
(C) Decreases time complexity and increases space complexity
(D) Increases both , time complexity and space complexity

Ans: (C) Decreases time complexity and increases space complexity

Ques 39: The problem 3-SAT and 2-SAT are:
(A) Both in P
(B) Both NP complete
(C) NP complete and P respectively
(D) undecidable and NP Complete respectively

Ans: (C) NP complete and P respectively
Solution: SAT problem is NP Complete but 2SAT can be solved efficiently in O ( n + m ) 
where is the number of variables and is the number of clauses.
|So complexity of 2SAT is polynomial time i.e P

Ques 40: What is the time complexity of fun()

int fun(int n)
{
int sum=0;
for(int i=n;i>0;i=i/2)
for(int j=0; j<i; j++)
{
sum=sum + (i+j);
}
return sum;
}

(A) O(log n)
(B) O(n)
(C) O(n log n)
(D) O(n2)

Ans: (B) O(n)

Ques 41: Suppose an application layer entity wants to send 1000 bytes of message to its peer over an TCP connection. What percentage of the transmitted bits belong to application if the header size of TCP , IP and Link Layer are 20,20,14 bytes respectively, and it takes 2 rounds of transmission.
(A) 90.25
(B) 94.87
(C) 98.93
(D) None of the above

Ans: (A) 90.25

Ques 42: When a client requests to communicate with the server listening on port 80 at the IP address of 14.139.35.2, say a socket connection gets formed. This connection is formed by which of the following socket pairs?
(A) 118:240:40:99:-1 and 14:139:35:2:80
(B) 118:240: 40:99:80 and 14:139:35:2:-80
(C) 118:240: 40:99:1025 and 14:139:35:2:80
(D) 118:240: 40:99:80 and 14:139:35:2:80

Ans: (C) 118:240: 40:99:1025 and 14:139:35:2:80

Ques 43: The size of network bits and host bits of class A of IP addresses is:
(A) Network bits 7, Host bits 24
(B) Network bits 8, Host bits 24
(C) Network bits 7, Host bits 23
(D) Network bits 8, Host bits 23


Ans: (A) Network bits 7, Host bits 24

Ques 44: Repeater operates in which layer of the OSI model?
(A) Physical
(B) Data Link
(C) Network
(D) Transport

Ans: (A ) Physical

Ques 45: An IP packet sent from source S crosses 10 intermediate routes, 10 switches to reach to a destination. Number of times IP checksum calculated in the entire transmission is :
(A) 10
(B) 2
(C) 12
(D) 20

Ans: (C) 12

Ques 46: Consider the following statements:
Statement 1: TCP has stronger detection of bit corruption than UDP
Statement 2: UDP flow control does not use sequence numbers.
(A) Both statements are correct
(B) Only statement 1 is correct
(C) Only statement 2 is correct
(D) Both statements are incorrect

Ans: (D) Both statements are incorrect

Ques 47: Assuming an arriving traffic rate of 9000 packets per second, an average packet length of 1250 bytes and a queue length of 1250 bytes and a queue length of 500 packets, What will be the queueing delay at a network link with a link rate of 100 Mbps
(A) 500 micro seconds
(B) 700 microseconds
(C) 900 microseconds
(D) None of the above

Ans: (C) 900 microseconds

Ques 48: Consider the following statements:
Statement 1: The optimal transmission probability in Slotted Aloha depends upon the length of the slot.
Statement 2: CSMA/CD is more efficient than Slotted Aloha
(A) Both statements are correct
(B) Only statement 1 is correct
(C) Only statement 2 is correct
(D) Both statements are incorrect

Ans: (C) Only statement 2 is correct

Ques 49: Assuming that we were using class based addressing , what type of network would the IP address 18.26.1.104 be a part of
(A) Class A
(B) Class B
(C) Class C
(D) Class D

Ans: (A) Class A

Ques 50: Which of the following is true statement about TCP?
(a) TCP segments can only be lost when router queues overflow.
(B) If the window size(represented in seconds) of a TCP connection is smaller than the RTT, the link will operate very efficiently.
(C) There is no performance benefit to having a window size (represented in seconds) larger than the RTT
(D) A receiver reduces the advertised window size in response to congestion at routers along the path.

Ans: (C) There is no performance benefit to having a window size (represented in seconds) larger than the RTT

error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.