You are on page 1of 5

1) If a Queue of capacity n is implemented using an array of size n+1 and is initialized

with REAR = FRONT = 0. Then what should be the condition to detect the full and
empty queue.

a) Full: (REAR+1) % (n+1) == FRONT, Empty: REAR == FRONT


b) Full: REAR % (n+1) == FRONT, Empty: REAR == FRONT
c) Full: (REAR+1) % n == FRONT, Empty: REAR == FRONT
d) Full: REAR % n == FRONT, Empty: (REAR+1) == FRONT

2) If 2 stacks are implemented using a single array of size n, each growing from
opposite ends. What would be the condition to check Overflow, so that memory can
be utilized effectively?

a) top1 == top2-1 and top2 == top1+1


b) top1==n/2 and top2==(n/2)+1
c) top1 == top2
d) Cannot implement 2 stacks in single array

3) Consider given C code and choose appropriate option.

unsigned int function(struct node* node)


{
if(node == NULL)
return 0;
if(node->left == NULL && node->right==NULL)
return 1;
else
return function(node->left) + function(node->right);
}

a) It counts total number of leaves in the binary tree.


b) It measures height of the binary tree.
c) It counts total number of nodes in binary tree.
d) None

4) In the Zero capacity queue : (choose two)

a) The queue has zero capacity


b) The sender blocks until the receiver receives the message
c) The sender keeps sending and the messages don’t wait in the queue
d) The queue can store at least one message

5) Inter process communication :

a) Allows processes to communicate and synchronize their actions when using the
same address space.
b) Allows processes to communicate and synchronize their actions without using the
same address space.
c) Allows the processes to only synchronize their actions without communication.
d) None of the mentioned

6) Which concept of oops does the below pseudo-code show us ?

//Functions written in same class


area(rock);
area(rock,socks);
area(rock,socks,takes)

a) Overloading
b) Abstraction
c) Encapsulation
d) None of the above

7) To enable a process to wait within the monitor,

a) A condition variable must be declared as condition


b) Condition variables must be used as boolean objects
c) Semaphore must be used
d) All of the mentioned

8) The operating system and the other processes are protected from being modified by
an already running process because:

a) They are in different memory spaces


b) They are in different logical addresses
c) They have a protection algorithm
d) every address generated by the CPU is being checked against the relocation and limit
registers
9) If the size of logical address space is 2 to the power of m, and a page size is 2 to the
power of n addressing units, then the high order bits of a logical address designate
the page number, and the ___ low order bits designate the page offset.

a) m, n
b) n, m
c) m – n, m
d) m – n, n

10) In C, what would be the output of the following code?

int a[] = {1,2,3,4,5,6};


a[6] = 10;

a) Syntax Error
b) Runtime Error
c) Executes Successfully
d) Compile Error

11) Where will ‘ob’ be stored?

class A
{
int a = 0;
}
A ob = new A();
a) Heap
b) Stack
c) Static Storage Area
d) Heap and Stack

12) Is overriding and overloading both static Polymorphism?

a) True
b) Overriding is dynamic polymorphism and Overloading is static polymorphism
c) Overriding is static polymorphism and overloading is dynamic polymorphism
d) Both are static polymorphism

13) Queue implemented using 2 Stacks:


void insert(int x)
{
push(S1,x);
}

int delete()
{
int x;
if(isEmpty(S2))
{
if(isEmpty(S1))
printf("Empty Queue");
else
while(!isEmpty(S1))
{
x=pop(S1);
push(S2,x);
}
}
return pop(S2);
}
If m insert and n(<=m) delete operation are carried out. If p and q are number of push and
pop performed respectively, Which among the following is True for all m and n?
a) m+n <= p <=2m and 2n <= y <=m+n
b) m+n <= p <=2m and 2m <= y <=2n
c) 2n <= p <=2m and 2m <= y <=n+m
d) 2n <= p <=2m and 2m <= y <=2n

14) What will the output for the given function? Assume Queue has been implemented
and has infinite capacity.

void func(int n)
{
int i,a,b;
Queue q;
insert(q,0);
insert(q,1);
for(i=0;i<n;i++)
{
a=delete(q);
b=delete(q);
insert(q,b);
insert(q,a+b);
printf("%d",a);
}
}

a) First n Fibonacci numbers


b) Numbers from 0 to n-1
c) None
d) Numbers from n-1 to 0

15) When Bubble Sort (ascending order) is applied on array A={78,95,65,99,24}, How
many swaps are done before element 95 is placed at its correct position.

a) 4
b) 7
c) 2
d) 6

You might also like