0% found this document useful (0 votes)
35 views107 pages

CAPG20-D1 Datastructures

The document contains a series of multiple-choice questions related to computer science concepts, including sorting, graph theory, data structures, and algorithms. Each question presents a scenario or concept and provides several answer options. The questions cover topics such as linked lists, binary trees, heaps, and time complexity.

Uploaded by

Mudadla.Poornima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views107 pages

CAPG20-D1 Datastructures

The document contains a series of multiple-choice questions related to computer science concepts, including sorting, graph theory, data structures, and algorithms. Each question presents a scenario or concept and provides several answer options. The questions cover topics such as linked lists, binary trees, heaps, and time complexity.

Uploaded by

Mudadla.Poornima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 107

Capgemini

Question 1
For which of the following tasks, sorting is useful?
1. Report Generation
2. Minimizing the storage needed
3. Making searching easier and efficient
Choose the correct answer from the options given below.

A) Only 1 and 3
B) Only 2 and 3
C) Only 1
D) Only 3
Question 1
For which of the following tasks, sorting is useful?
1. Report Generation
2. Minimizing the storage needed
3. Making searching easier and efficient
Choose the correct answer from the options given below.

A) Only 1 and 3
B) Only 2 and 3
C) Only 1
D) Only 3
Question 2
A/An _______ is a subset of Graph G, which has all the vertices
covered with minimum possible number of edges

A) spanning tree
B) binary tree
C) avl-tree
D) binary search tree
Question 2
A/An _______ is a subset of Graph G, which has all the vertices
covered with minimum possible number of edges

A) spanning tree
B) binary tree
C) avl-tree
D) binary search tree
Question 3
In an undirected graph G, depth-first traversal is performed and let
T be the resulting depth-first search tree. If u be a vertex in G and
v be the first new (unvisited) vertex visited after visiting u in the
traversal, then which of the following statements is always true?

A) If {u, v} is not an edge in G, then u is a leaf in T


B) {u, v} must be an edge in G, and u is a descendant of v in T
C) If {u, v} is not an edge in G then u and v must have the same
D) {u, v} must
parent in T be an edge in G, and v is a descendant of u in T
Question 3
In an undirected graph G, depth-first traversal is performed and let
T be the resulting depth-first search tree. If u be a vertex in G and
v be the first new (unvisited) vertex visited after visiting u in the
traversal, then which of the following statements is always true?

A) If {u, v} is not an edge in G, then u is a leaf in T


B) {u, v} must be an edge in G, and u is a descendant of v in T
C) If {u, v} is not an edge in G then u and v must have the same
D) {u, v} must
parent in T be an edge in G, and v is a descendant of u in T
Question 4
Which of the following statements is true regarding linked list
implementation of Queue?
1. In a push operation, if new nodes are inserted at the beginning
of the linked list, then in pop operation, nodes must be removed
from the end
2. In a push operation, if new nodes are inserted at the end, then
A) in Only
pop operation,
2 nodes must be removed from the beginning.
B) Only 1
C) Neither 1 nor 2
D) Both 1 and 2
Question 4
Which of the following statements is true regarding linked list
implementation of Queue?
1. In a push operation, if new nodes are inserted at the beginning
of the linked list, then in pop operation, nodes must be removed
from the end
2. In a push operation, if new nodes are inserted at the end, then
A) in Only
pop operation,
2 nodes must be removed from the beginning.
B) Only 1
C) Neither 1 nor 2
D) Both 1 and 2
Question 5
Linked lists are not a suitable data structure for which of the
following problems?

A) Insertion sort
B) Binary search
C) Radix sort
D) None of the mentioned options
Question 5
Linked lists are not a suitable data structure for which of the
following problems?

A) Insertion sort
B) Binary search
C) Radix sort
D) None of the mentioned options
Question 6
Pick out the correct statement to be filled in ‘if’ loop to meet the
“is empty” condition in a queue.
Code/Pseudo Code
1 bool isempty() {

2 if(________)

3 return true;

4 else

5 return false;

6 }

7
8
9
10
11
12
13
14
Question 6

A) front < 0 || front > rear


B) front < 0 && front > rear
C) front > 0 || front < rear
D) front > 0 && front < rear
Question 6

A) front < 0 || front > rear


B) front < 0 && front > rear
C) front > 0 || front < rear
D) front > 0 && front < rear
Question 7
The total number of possible positions in a min-heap of ‘n’
elements, where the third largest element can be stored is:

A) 3
B) 5
C) 7
D) 6
Question 7
The total number of possible positions in a min-heap of ‘n’
elements, where the third largest element can be stored is:

A) 3
B) 5
C) 7
D) 6
Question 8
What would be the minimum number of arithmetic operations
required to evaluate the polynomial p(x) = (x5 + 4x3 + 6x + 5) for
a given value of “x” using only one temporary variable?

A) None of the mentioned options


B) 8
C) 6
D) 7
Question 8
What would be the minimum number of arithmetic operations
required to evaluate the polynomial p(x) = (x5 + 4x3 + 6x + 5) for
a given value of “x” using only one temporary variable?

A) None of the mentioned options


B) 8
C) 6
D) 7
Question 9
Consider the given recurrence T(n) = T(n/2) + n. What will its
solution?

A) 0(n log n)
B) 0(n)
C) 0(n/2)
D) 0(log n)
Question 9
Consider the given recurrence T(n) = T(n/2) + n. What will its
solution?

A) 0(n log n)
B) 0(n)
C) 0(n/2)
D) 0(log n)
Question 10
Which of the following formula will correctly calculate the memory
address of the third element of an array? (w is the number of
words per memory cell for the array)

A) Information is not adequate to solve the given problem


B) LOC(Array [3]) = Base (Array) + w(3 – lower bound)
C) LOC(Array [3]) = Base (Array[4]) + w(3 – upper bound)
D) LOC(Array [3]) = Base (Array[3]) + (3 – lower bound)
Question 10
Which of the following formula will correctly calculate the memory
address of the third element of an array? (w is the number of
words per memory cell for the array)

A) Information is not adequate to solve the given problem


B) LOC(Array [3]) = Base (Array) + w(3 – lower bound)
C) LOC(Array [3]) = Base (Array[4]) + w(3 – upper bound)
D) LOC(Array [3]) = Base (Array[3]) + (3 – lower bound)
Question 11
What will be the number of null branches for a binary tree with 20
nodes?

A) 21
B) 22
C) 19
D) 20
Question 11
What will be the number of null branches for a binary tree with 20
nodes?

A) 21
B) 22
C) 19
D) 20
Question 12
What will be the result of the following code snippet for the input =
1, 2, 3, 4, 5?
Code/Pseudo Code
1 void Test2(struct node* head)

2 {

3 if(head == NULL)

4 return;

5 printf(“%d”, head -> data);

6 if(head -> next!= NULL)

7 Test2(head -> next -> next);

8 printf(“%d”, head -> data);

9 }

10
11
12
13
14
Question 12

A) 5, 4, 3, 2, 1
B) 1, 3, 5, 5, 3, 1
C) 2, 4, 4, 2, 1
D) 1, 3, 5, 4, 2
Question 13
What is the time complexity of Bellman-Ford single-source shortest
path algorithm on a complete graph of n vertices?

A) ᶿ(n3 logn)
B) ᶿ(n2)
C) ᶿ(n3)
D) ᶿ(n2 log n)
Question 13
What is the time complexity of Bellman-Ford single-source shortest
path algorithm on a complete graph of n vertices?

A) ᶿ(n3 logn)
B) ᶿ(n2)
C) ᶿ(n3)
D) ᶿ(n2 log n)
Question 14
Let a max heap represented by the array: 40, 30, 20, 10, 15, 16,
17, 18, 4. Now if we want to insert a value 35 into this heap. After
the insert operation, the new heap is:

A) 40, 35, 20, 10, 30, 16, 17, 8, 4, 15


B) 40, 30, 20, 10, 35, 16, 17, 8, 4, 15
C) 40, 30, 20, 10, 15, 16, 17, 8, 4, 35
D) 40, 35, 20, 10, 15, 16, 17, 8, 4, 30
Question 14
Let a max heap represented by the array: 40, 30, 20, 10, 15, 16,
17, 18, 4. Now if we want to insert a value 35 into this heap. After
the insert operation, the new heap is:

A) 40, 35, 20, 10, 30, 16, 17, 8, 4, 15


B) 40, 30, 20, 10, 35, 16, 17, 8, 4, 15
C) 40, 30, 20, 10, 15, 16, 17, 8, 4, 35
D) 40, 35, 20, 10, 15, 16, 17, 8, 4, 30
Question 15
If the only use of lazy lists in a given application is monolithic, then
that application:

A) None of the mentioned options


B) Should use complex unsuspended lists
C) Should use simple suspended lists rather than streams.
D) Should use streams
Question 15
If the only use of lazy lists in a given application is monolithic, then
that application:

A) None of the mentioned options


B) Should use complex unsuspended lists
C) Should use simple suspended lists rather than streams.
D) Should use streams
Question 16
Consider the following inputs:
4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199
If the hash function x mode 10 is used, which of the following
statements is/are true regarding the above statement?
1. 9679, 1989, 4199 hash to the same value
2. 1471, 6171 hash to the same value
3. 1471, 1989, 6171 hash to the same value
4. 6171, 4199 hash to the same value
A) Only 1
B) Only 2
C) Only 1 and 2
D) Only 3 and 4
Question 16
Consider the following inputs:
4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199
If the hash function x mode 10 is used, which of the following
statements is/are true regarding the above statement?
1. 9679, 1989, 4199 hash to the same value
2. 1471, 6171 hash to the same value
3. 1471, 1989, 6171 hash to the same value
4. 6171, 4199 hash to the same value
A) Only 1
B) Only 2
C) Only 1 and 2
D) Only 3 and 4
Question 17
Which of the following data structure does not keep the track of
address of every element in the list?

A) Queue
B) String
C) Stack
D) Linear Array
Question 17
Which of the following data structure does not keep the track of
address of every element in the list?

A) Queue
B) String
C) Stack
D) Linear Array
Question 18
The working principle of the queue is:
1. First-In-First-Out(FIFO)
2. Last-In-First-Out(LIFO)

Choose the correct answer from the options given below.

A) Only 1
B) Neither 1 nor 2
C) Both 1 and 2 depending on the situation
D) Only 2
Question 18
The working principle of the queue is:
1. First-In-First-Out(FIFO)
2. Last-In-First-Out(LIFO)

Choose the correct answer from the options given below.

A) Only 1
B) Neither 1 nor 2
C) Both 1 and 2 depending on the situation
D) Only 2
Question 19
Manipulating data on a __________ is as same as accessing data
stored in a tape.

A) Stack
B) Queue
C) List
D) Reap
Question 19
Manipulating data on a __________ is as same as accessing data
stored in a tape.

A) Stack
B) Queue
C) List
D) Reap
Question 20
Suppose a binary search tree is generated by inserting in order of
the following integers: 50, 15, 52, 5, 20, 58, 91, 3, 8, 37, 60, 24
What would be the number of nodes in the left subtree and right
subtree of the root respectively?

A) 8, 3
B) 7, 4
C) 4, 7
D) 3, 8
Question 20
Suppose a binary search tree is generated by inserting in order of
the following integers: 50, 15, 52, 5, 20, 58, 91, 3, 8, 37, 60, 24
What would be the number of nodes in the left subtree and right
subtree of the root respectively?

A) 8, 3
B) 7, 4
C) 4, 7
D) 3, 8
Question 21
Which of the following statements is true regarding the linked list?
1. Using a singly linked list and a circular list, it is not possible to
traverse the list backwards.
2. To find the predecessor, it is required to traverse the list from
the first node in the case of a singly linked list.
Choose the correct answer from the options given below.
A) Only 2
B) Both 1 and 2
C) Neither 1 nor 2
D) Only 1
Question 21
Which of the following statements is true regarding the linked list?
1. Using a singly linked list and a circular list, it is not possible to
traverse the list backwards.
2. To find the predecessor, it is required to traverse the list from
the first node in the case of a singly linked list.
Choose the correct answer from the options given below.
A) Only 2
B) Both 1 and 2
C) Neither 1 nor 2
D) Only 1
Question 22
A stack is implemented using a priority queue that stores
characters. PUSH(C) is implemented as INSERT(Q, C, K). K is
defined as an appropriate integer key chosen by the
implementation. POP is implemented as DELETEMIN(Q). Consider a
sequence of operations, find the correct order of the keys.

A) Non-decreasing order
B) Strictly increasing order
C) Strictly decreasing order
D) Non-increasing order
Question 22
A stack is implemented using a priority queue that stores
characters. PUSH(C) is implemented as INSERT(Q, C, K). K is
defined as an appropriate integer key chosen by the
implementation. POP is implemented as DELETEMIN(Q). Consider a
sequence of operations, find the correct order of the keys.

A) Non-decreasing order
B) Strictly increasing order
C) Strictly decreasing order
D) Non-increasing order
Question 23
To which of the following domain problems does the knapsack
problem belong?

A) NP Complete
B) Sorting
C) Optimization
D) Linear Solution
Question 23
To which of the following domain problems does the knapsack
problem belong?

A) NP Complete
B) Sorting
C) Optimization
D) Linear Solution
Question 24
What is the maximum possible number of nodes in a binary tree at
level 6?

A) 63
B) 31
C) 127
D) 128
Question 24
What is the maximum possible number of nodes in a binary tree at
level 6?

A) 63
B) 31
C) 127
D) 128
Question 25
Which of the following is the correct condition to be filled in ‘if’
statement to meet the “is full” condition in stack?
Code/Pseudo Code
1 bool isfull() {

2 if(__________)

3 return true;

4 else

5 return false;

6 }

7
8
9
10
11
12
13
14
Question 25

A) top > MAXSIZE


B) top == MINSIZE
C) top > MINSIZE
D) top == MAXSIZE
Question 25

A) top > MAXSIZE


B) top == MINSIZE
C) top > MINSIZE
D) top == MAXSIZE
Question 26
How many minimum number of queue(s) is/are needed to
implement the priority queue?

A) Three
B) Two
C) One
D) Depends on the application
Question 26
How many minimum number of queue(s) is/are needed to
implement the priority queue?

A) Three
B) Two
C) One
D) Depends on the application
Question 27
Data in the linked list is stored in:
1. Adjacent location
2. Different location in memory

Choose the correct answer from the options given below

A) Only 1
B) Neither 1 nor 2
C) Only 2
D) Either 1 or 2
Question 27
Data in the linked list is stored in:
1. Adjacent location
2. Different location in memory

Choose the correct answer from the options given below

A) Only 1
B) Neither 1 nor 2
C) Only 2
D) Either 1 or 2
Question 28
Which of the following sorting algorithms does not have a worst-
case running time of O(n2)?

A) Merge sort
B) Bubble sort
C) Quick sort
D) Insertion sort
Question 28
Which of the following sorting algorithms does not have a worst-
case running time of O(n2)?

A) Merge sort
B) Bubble sort
C) Quick sort
D) Insertion sort
Question 29
Which of the following data structure uses hierarchical data
model?

A) Queue
B) Array
C) Tree
D) Stack
Question 29
Which of the following data structure uses hierarchical data
model?

A) Queue
B) Array
C) Tree
D) Stack
Question 30
Which of the following operations is possible on doubly linked list?

A) Display backward
B) Delete Last
C) Insert Last
D) All of the mentioned options
Question 30
Which of the following operations is possible on doubly linked list?

A) Display backward
B) Delete Last
C) Insert Last
D) All of the mentioned options
Question 31
Which of the following is NOT a type of linked list?

A) Doubly Linked List


B) Circular Linked List
C) Simple Linked List
D) Double ended Linked List
Question 31
Which of the following is NOT a type of linked list?

A) Doubly Linked List


B) Circular Linked List
C) Simple Linked List
D) Double ended Linked List
Question 32
A machine took 200 seconds to sort 200 names, using bubble sort.
In 800 seconds, it can approximately sort:

A) 750 names
B) 850 names
C) 800 names
D) 400 names
Question 32
A machine took 200 seconds to sort 200 names, using bubble sort.
In 800 seconds, it can approximately sort:

A) 750 names
B) 850 names
C) 800 names
D) 400 names
Question 33
Periodic collection of all the free memory space to form a
contiguous block of free space by an operating system is called:

A) Concatenation
B) Garbage collection
C) Collision
D) Dynamic Memory Allocation
Question 33
Periodic collection of all the free memory space to form a
contiguous block of free space by an operating system is called:

A) Concatenation
B) Garbage collection
C) Collision
D) Dynamic Memory Allocation
Question 34
What do we call the binary tree nodes with no successor?

A) Final Nodes
B) Last Nodes
C) End Nodes
D) Terminal Nodes
Question 34
What do we call the binary tree nodes with no successor?

A) Final Nodes
B) Last Nodes
C) End Nodes
D) Terminal Nodes
Question 35
For a sorted array of, what would be the minimum number of
comparisons required to determine if an integer is appearing more
than n/2 times in the sorted array of n integers?

A) O(n2)
B) O(log n)
C) O(log * n)
D) O(1)
Question 35
For a sorted array of, what would be the minimum number of
comparisons required to determine if an integer is appearing more
than n/2 times in the sorted array of n integers?

A) O(n2)
B) O(log n)
C) O(log * n)
D) O(1)
Question 36
What will be the value of r in a circular queue?

A) r = (r + 1)% QUEUE_SIZE
B) r = (r + 1)% [QUEUE_SIZE – 1]
C) r = (r - 1)% QUEUE_SIZE
D) r–r+1
Question 36
What will be the value of r in a circular queue?

A) r = (r + 1)% QUEUE_SIZE
B) r = (r + 1)% [QUEUE_SIZE – 1]
C) r = (r - 1)% QUEUE_SIZE
D) r–r+1
Question 37
What do we call the highest element of an array’s index?

A) Lower bound
B) Range
C) Upper bound
D) Extraction
Question 37
What do we call the highest element of an array’s index?

A) Lower bound
B) Range
C) Upper bound
D) Extraction
Question 38
A cyclic digrapgh, which has only one node with indegree 0, and
other nodes have in-degree 1 is called:

A) Direction oriented tree


B) Disjoint tree
C) Undirected tree
D) Directed tree
Question 38
A cyclic digrapgh, which has only one node with indegree 0, and
other nodes have in-degree 1 is called:

A) Direction oriented tree


B) Disjoint tree
C) Undirected tree
D) Directed tree
Question 39
Consider the following operation along with Enqueue and Dequeue
operations on queues, where k is a global parameter
Code/Pseudo Code
1 MultiDequeue (Q)

2 {

3 n = k

4 while (Q is not empty) and (n > 0)

5 {

6 Dequeue (Q)

7 n = n-1

8 }

9 }

10
11
12
13
14
Question 39
What is the worst-case time complexity of a sequence of ‘m’
MultiDequeue () operations on an initially empty queue?

A) ᶿ(mk)
B) ᶿ(m)
C) ᶿ(m + k)
D) ᶿ(m2)
Question 39
What is the worst-case time complexity of a sequence of ‘m’
MultiDequeue () operations on an initially empty queue?

A) ᶿ(mk)
B) ᶿ(m)
C) ᶿ(m + k)
D) ᶿ(m2)
Question 40
Which of the following data types represents many to many
relations?

A) Tree
B) Plex
C) Graph
D) Both Plex and Graph
Question 40
Which of the following data types represents many to many
relations?

A) Tree
B) Plex
C) Graph
D) Both Plex and Graph
Question 41
A complete graph can have ______ spanning trees

A) n2
B) nn - 2
C) nn + 1
D) nn
Question 41
A complete graph can have ______ spanning trees

A) n2
B) nn - 2
C) nn + 1
D) nn
Question 42
Data structure representation in memory is termed as:

A) Storage structure
B) Abstract data type
C) Recursive data type
D) File structure
Question 42
Data structure representation in memory is termed as:

A) Storage structure
B) Abstract data type
C) Recursive data type
D) File structure
Question 43
Suppose queue is implemented using a linked list and its front
node and rear nodes are tracked by two reference variables. Which
of these reference variables will change during an insertion into a
NONEMPTY queue?

A) Only front changes


B) Only rear changes
C) Both will change
D) Neither changes
Question 43
Suppose queue is implemented using a linked list and its front
node and rear nodes are tracked by two reference variables. Which
of these reference variables will change during an insertion into a
NONEMPTY queue?

A) Only front changes


B) Only rear changes
C) Both will change
D) Neither changes
Question 44
The order of an internal node in a B+ tree index is the maximum
number of children it can have. Suppose, a child pointer takes 5
bytes, the search field value takes 15 bytes, and the block size is 5
x 512 bytes. What is the order of the internal node?

A) 128
B) 281
C) 270
D) 120
Question 44
The order of an internal node in a B+ tree index is the maximum
number of children it can have. Suppose, a child pointer takes 5
bytes, the search field value takes 15 bytes, and the block size is 5
x 512 bytes. What is the order of the internal node?

A) 128
B) 281
C) 270
D) 120
Question 45
An abstract Data Type is defined to be a mathematical model of a
user-defined type along with the collection of all ________
operations on that model.

A) union
B) assignment
C) primitive
D) None of the mentioned options
Question 45
An abstract Data Type is defined to be a mathematical model of a
user-defined type along with the collection of all ________
operations on that model.

A) union
B) assignment
C) primitive
D) None of the mentioned options
Question 46
Each node of the graph is represented as a _____________.

A) Vertex
B) Root
C) Path
D) Edge
Question 46
Each node of the graph is represented as a _____________.

A) Vertex
B) Root
C) Path
D) Edge
Question 47
Suppose a stack implementation supports an instruction REVERSE,
which reverses the order of elements on the stack, in addition to
the PUSH and POP instructions. Which of the following statements
is TRUE with respect to this modified stack?

A) A queue cannot be implemented using this stack


B) A queue can be implemented where ENQUEUE takes a
sequence of three instructions and DEQUEUE takes a single
instruction.
A queue can be implemented where ENQUEUE takes a single
C)
instruction and DEQUEUE takes a sequence of two
instructions
A queue can be implemented where both ENQUEUE and
D)
DEQUEUE take a single instruction each
Question 47
Suppose a stack implementation supports an instruction REVERSE,
which reverses the order of elements on the stack, in addition to
the PUSH and POP instructions. Which of the following statements
is TRUE with respect to this modified stack?

A) A queue cannot be implemented using this stack


B) A queue can be implemented where ENQUEUE takes a
sequence of three instructions and DEQUEUE takes a single
instruction.
A queue can be implemented where ENQUEUE takes a single
C)
instruction and DEQUEUE takes a sequence of two
instructions
A queue can be implemented where both ENQUEUE and
D)
DEQUEUE take a single instruction each
Question 48
When we update an imperative data structure we typically accept
that:

A) the old version of the data structure will be available


B) both old and new version of data structures will be available
C) None of the mentioned options
D) the old version of the data structure will no longer be
available
Question 48
When we update an imperative data structure we typically accept
that:

A) the old version of the data structure will be available


B) both old and new version of data structures will be available
C) None of the mentioned options
D) the old version of the data structure will no longer be
available
Question 49
Recursion uses more memory space than iteration. Which of the
following is/are the valid reason for the same?
A. It uses the stack instead of a queue
B. Every recursive call has to be stored
Choose the correct answer from the options given below.

A) Only A
B) Both A and B
C) Neither A nor B
D) Only B
Question 49
Recursion uses more memory space than iteration. Which of the
following is/are the valid reason for the same?
A. It uses the stack instead of a queue
B. Every recursive call has to be stored
Choose the correct answer from the options given below.

A) Only A
B) Both A and B
C) Neither A nor B
D) Only B
THANK YOU

You might also like