A Learning Portal from Recruitment India

When a Nonstrict-read-write concurrency strategy is to be used?

A.

Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern

B.

Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions

C.

Use it for reference data only

D.

None of the above

Answer with explanation

Answer: Option AExplanation

The correct answer is Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern

The constrict-read-write strategy makes no guarantee of consistency between the cache and the database. Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern

Workspace

What would be the time complexity if the user tries to insert the element at the end of the linked list (head pointer is known)?

A.

O(nlogn)

B.

O(logn)

C.

O(n)

D.

O(1)

Answer with explanation

Answer: Option CExplanation

The answer is b, i.e., O(n). As it is mentioned in the above question that head pointer is known, so to insert the node at the end of the linked list; we have to traverse till the nth node. Therefore, the time complexity would be O(n).

Workspace

Which data structure is the best for implementing a priority queue?

A.

Heap

B.

Array

C.

Linked list

D.

Stack

Answer with explanation

Answer: Option AExplanation

The correct answer is Heap

Heap. All the data structures that are given in the above options can be used to implement a priority queue but the most efficient way of implementing a priority queue is a heap data structure.

Workspace

In the linked list implementation of queue, where will the new element be inserted?

A.

At the tail position of the linked list

B.

At the head position of the linked list

C.

At the middle position of the linked list

D.

None of the above

Answer with explanation

Answer: Option AExplanation

The correct answer is At the tail position of the linked list

If the queue is implemented using a linked list, then the new element will be inserted at the tail position of the linked list as Queue follows the FIFO principle in which a new element will always be added at the end of the Queue

Workspace

Which one of the following is the overflow condition if a circular queue is implemented using an array having size MAX?

A.

front=(rear+1) mod max

B.

rear=MAX

C.

rear= MAX-1

D.

None of the above

Answer with explanation

Answer: Option AExplanation

The correct answer is front=(rear+1) mod max

front=(rear+1) mod max. The overflow condition for the linear queue is rear =MAX-1 as there is no space left in the Queue if rear = MAX-1. On the other hand, in a circular queue, the overflow condition is front=(rear+1) mod max because the last element is connected to the first element in a circular queue.

Workspace

…….. level is where the model becomes compatible executable code

A.

Implementation level

B.

Application-level

C.

Abstract level

D.

All of the above

Answer with explanation

Answer: Option AExplanation

The correct answer is Implementation level

Implementation level is where the model becomes compatible executable code

Workspace

Interpolation search is an improved variant of binary search. It is necessary for this search algorithm to work that

A.

data collection should be equally distributed but not sorted

B.

data collection should be in sorted form and but not equally distributed.

C.

data collection should be in sorted form and equally distributed.

D.

None of the above.

Answer with explanation

Answer: Option CExplanation

The correct answer is data collection should be in sorted form and equally distributed.

For this algorithm to work properly the data collection should be in sorted form and equally distributed

Workspace

After each iteration in bubble sort….

A.

one less comparison is made in the next iteration.

B.

at least one element is at its sorted position.

C.

Both A & B are true.

D.

Neither A nor B are true.

Answer with explanation

Answer: Option BExplanation

The correct answer is at least one element is at its sorted position

In one iteration of Bubble sort, the maximum of the set in hand is moved at the end of the unsorted list. Hence one less comparison

Workspace

What data structure is used for the breadth-first traversal of a graph?

A.

list

B.

stack

C.

queue

D.

none of the above

Answer with explanation

Answer: Option CExplanation

The correct answer is Queue is used for breadth-first traversal whereas stack is used for depth-first traversal

Workspace

Which data structure is mainly used for implementing the recursive algorithm?

A.

Stack

B.

Linked list

C.

Binary tree

D.

Queue

Answer with explanation

Answer: Option AExplanation

The correct answer is Stack

Recursion means calling the function itself again. Stack is used to maintaining the previous records of the function

Workspace

Which one of the following is the process of inserting an element in the stack?

A.

Push

B.

Add

C.

Insert

D.

None of the above

Answer with explanation

Answer: Option AExplanation

The correct answer is Push

In a stack, the process of inserting an element is known as a push operation.

Workspace

What is the output of the below code?

#include <stdio.h>

int main()

{

int arr[5]={10,20,30,40,50};

printf(“%d”, arr[5]);

return 0;

}

A.

50

B.

10

C.

Garbage value

D.

None of the above

Answer with explanation

Answer: Option CExplanation

The correct answer is Garbage value

the indexing in an array starts from 0, so it starts from arr[0] to arr[4]. If we try to access arr[5] then the garbage value will be printed.

Workspace

Which of the following is the disadvantage of the array?

A.

Wastage of memory if the elements inserted in an array are lesser than the allocated size

B.

Elements can be accessed sequentially

C.

Stack and Queue data structures can be implemented through an array

D.

Index of the first element in an array can be negative

Answer with explanation

Answer: Option AExplanation

The correct answer is Wastage of memory if the elements inserted in an array are lesser than the allocated size

For example, if we have an array of size 10 elements and we have inserted only 5 elements in an array then there is a wastage of 5 memory blocks which cannot be utilized by another variable.

Workspace

How can we initialize an array in the C language?

A.

int arr(2) = (10, 20)

B.

int arr[2] = {10, 20}

C.

int arr(2)={10, 20}

D.

int arr[2]=(10, 20)

Answer with explanation

Answer: Option BExplanation

The correct answer is int arr[2] = {10, 20}

the values assigned to the array must be enclosed within a curly bracket.

Workspace

How can we describe an array in the best possible way?

A.

The Array is not a data structure

B.

Container that stores the elements of similar types

C.

The Array shows a hierarchical structure.

D.

Arrays are immutable.

Answer with explanation

Answer: Option BExplanation

The answer is a Container that stores the elements of similar types because the array stores the elements in a contiguous block of memory of similar types. Therefore, we can say that array is a container that stores the elements of similar types

Workspace

Correct Answer 👍

Wrong Answer 👎