0% found this document useful (0 votes)
28 views

Data Structures

Uploaded by

Ayan Haque
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Data Structures

Uploaded by

Ayan Haque
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Capgemini Data Structure 1

1. Which among the following is true about Queues?


i:)These are abstract data structures ii:) These follows
the FIFO order iii.)Insertion and deletion is performed
at one end only
a) i and ii
b) ii and iii
c) i and iii
d) i,ii, and iii
Ans:- i and ii
2. Queues in the application areas are implied as the------

a) Templates parameters
b) Member types
c) Container adaptors
d) Function
Ans container adaptors
3. Different types of Queues are
a) Circular queue
b) Priority queue
c) Doubly ended queue
d) All of the above
Ans : - all of the above
4. To implement a stack, how many ques are required?
a) One b. two

C. three d. four

Ans : two

5. The priority queue of pairs can two type of ordering


a) Ordered by the first element of pair
b) Ordered by the second element of pair
c) Either a and b
d) Both a and b
Ans:- both a and b
6. Which among the following is an application of queue?
i:) Flood Fill Algorithm
ii:)Chess Knight Problem
iii:)Shortest path in a maze
a) i and ii
b) ii and iii
c) I and iii
d) I,ii,iii
Ans:- I,ii,iii
7. What is the benefit of using a circular queue?
The iterator can comeback to start

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
a) when he reaches last
b) b. There is no end iterator for circular queue
c) a and b
d) None of the above
Ans:- a and b

8. What are the basic queue operations?


a) Enqueue and Dequeue
b) Is Empty and is Full
c) Front
d) All of the above
Ans all of the above
9. Priority Queue is the extension of the queue comprising the features.
i. Each object has its related priority.
ii. The high priority element is dequeued from the low priority element. iii. If
two elements have the same priority, any of them are executed
a) i and ii
b) ii and iii
c) I and iii
d) I,ii,iii
Ans I and ii
10. The c++ containers used to build priority queues:-
a) Vectors
b) Adaptors
c) Dequeues
d. a and c
ans a and c
1. A priority queue is introduced by building a data system explicitly called:-
a. Binary trees
b. b- trees
c. heap
d. list
ans heap
2. Monotone priority queues are queues for the
a. the case where no item is ever inserted that has a lower priority
b. the case where no item is ever inserted that has a higher priority
c. a and b
d. none of these ans the case where no item is ever inserted that has a lower priority
3. the double-ended queue is often named as
a. deque
b. deck
c. head-tail linked list
d. all ans all

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
4. In a doubly ended queue, elements cannotbe inserted at:-
a. At the end
b. At the beginning
c. At the middle
d. At the tail
Ans at the middle
5. Head-tail linked list is of how many types
a. One
b. Two
c. Three
d. a or b ans two
6. What is true about an input-restricted deck?
a. deletion can be made from both ends, but insertion can be made at one end only.
b. insertion can be made from both ends, but deletion can be made at one end only
c. deletion and insertion can be made at one end only
d. a and b

ans deletion can be made from both ends, but insertion can be made at one end only.

7. What is true about an output-restricted double ended queue?


a. deletion can be made from both ends, but insertion can be made at one end only.
b. insertion can be made from both ends, but deletion can be made at one end only.
c. deletion and insertion can be made at one end only.
d. a and b
Ans insertion can be made from both ends, but deletion can be made at one end only.
8. Application of priority Queue:-
a. CPU
b. Dijkstra`s shortest path algorithm
c. Prim`s Minimum Spanning tree
d. All
Ans all
9. What are the ways to efficiently implement a deque
a. Dynamic array
b. Doubly linked list
c. A and b
d. None of the these
Ans a and b
10. What is the basic operations on a deck are:-
a. Enqueue on either end
b. Append and peek
c. Enqueue and dequeue on either end
d. Peek on both ends
Ans Enqueue and dequeue on either end
1. Which among the following is true about Array?

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
i.is a collection of similar type of element ii. uses continues memory

locations to store every data item of array iii .Once the size of the Array is defined,

then the size of the array can not be modified

iv. all the above

a. i and ii
b. ii and iii
c. I and iii
d. Iv
Ans iv
2. How many type array there:-
a. 1-D array
b. 2-D array
c. Multidimensional array
d. All the above
Ans All the above
3. How to represent array elements in the code :-
a. int marks[5]; b. int marks[6]={19,2,10,8,61); arr[0]=9; arr[1]=1;
arr[2]=4; arr[3]=18; arr[4]=15;

c. int marks[6]={19,2,10,8,61); d. All the above

ans all the above

4. Which of these best describes an array?


a. A data structure that shows a hierarchical behavior
b. Container of objects of similar types
c. Arrays are immutable once
d. Array is not a data structure
Ans Container of objects of similar types
5. Difference between 1-D array and 2-D or multidimensional array :-
a. in a 2-D array, elements are stored in a matrix format rather than in a linear manner
b. in 2-d array,the elements are stored in rows and columns like a matrix.
c. Both use linear manner to store elements in the array
d. a and b
ans a and b
6. How do declare and instantiate elements in an array in java?
a. Int arr []=new int [5];
b. Int arr[];
c. Int arr()=new int (3);
d. Int arr[]= new int (9);
e. Ans Int arr []=new int [5];
7. When does the arrayindexoutofBoundsException occur?
a. Run- time

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
b. Compile
c. Not an exception
d. Not an error
Ans Run- time
8. Predict the output public class array
{
public static void main(String args[])
{

int []arr = {11,12,13,14,15};


System.out.println(arr[5]);
}
}
a. 15
b. Compile-time
c. Invalid InputException
d. ArrayIndexOutOfBoundsException Ans ArrayIndexOutOfBoundsException
9. What are the disadvantages of arrays?
a. Queue or stack cannot be implemented in the array
b. There are chances of wastage of memory space if elements inserted in an array are
lesser than the allocated size
c. Easier to store elements of same data type
d. Index value of an array can be negative
Ans There are chances of wastage of memory space if elements inserted in an array are
lesser than the allocated size
10. If int has 4-bytes then what is the size of int arr[5]?
a. 20
b. 9
c. 19
d. 25
Ans 20
1. When you passed an array as an argument to the function then what does it mean?
a. Base address of the array
b. Base address of the array of first element
c. Base address of the array of last element
d. Address of the array
Ans Base address of the array
2. Assume that float takes 4 bytes, Predict the output #include <stdio.h> int main()
{
float arr[5] = {12.5, 10.0, 13.5, 90.5,
0.5}; float *ptr1 = &arr[0]; float *ptr2 = ptr1
+ 3; printf("%f", *ptr2); printf("%d", ptr2
ptr1);
return 0;

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
}
a. 0.500000013
b. 10.00000012
c. 90.5000003
d. 90.50000012
Ans 90.5000003
3. A pointer to a block of memory is effectively same as an array.
a. Yes
b. No
c. Depends
d. None
Ans yes
4. Which of the following concepts make extensive use of arrays?
a. Binary trees
b. Scheduling of processes
c. Caching
d. Spatial locality
Ans Spatial location
5. Are the expression arr and &arr same for an array of 16 integers?
a. Yes
b. No
c. Depends
d. None
Ans no
6. What is output of the code?
int main() { int
a[5]={1,3,6};
printf("%d",a[4]);
}
a. Initialization of elements is not correct
b. 0
c. Compile time error
d. Syntax error
Ans 0
7. How to a access elements in an array?
a. Randomly
b. Sequentially
c. Exponentially
d. Partially
Ans randomly
8. what will be the output of the below code?
int main()
{ int a,b,c; int
ar[5]={11,1,16,2,7}; a

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
= ++ar[1]; b = ar[1]++;
c = ar[a++];

printf("%d %d %d",a,b,c);

}
a. 2,2,2
b. 3,2,16
c. 2,3,16
d. 2,3,2
Ans 3,2,16
9. What will be the output of code?
int main()
{
char a;
char arr[7] = {10,11,12,13,14,15,17};
a. = (arr+3) [3];
printf("%d",a);
}
a. 12
b. 13
c. 15
d. 17
Ans 17
10. What is the maximum dimension that an array can have is :-
a. theoretically it has no limit but
practically limit depends on memory
b. depends on multidimensional array
c. 1-D array
d. None
Ans theoretically it has no limit but
practically limit depends on memory
1. Which among the following is true about Stack?
I: These are abstract data structures
II: These follows the LIFO order
III. Insertion and deletion is performed at one end only a.
I and ii
b. Ii and iii
c. I and iii
d. I,ii,iii
Ans I,ii,iii
2. Insertion of an element in the stack is called----
a. Load
b. Fill
c. Push
d. Pop

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
Ans push
3. Deletion of an element in the stack is called-----------
a. Delete
b. Remove
c. Push
d. Pop
Ans pop
4. When the stack returns the topmost item is called------
a. Top item
b. Last element
c. Peek
d. Pop
Ans peek
5. Applications where we can use stack?
a. A parentheses balancing program
b. Compiler syntax Analyzer
c. All of the mentioned
d. Teacking of local variables at run time Ans All of the mentioned
6. How can we insert different type of data in the stack?
a. Union
b. Structure
c. a and b
d. none
ans a and b
7. Removing an element from an empty stack is called_______.
a. Overflow
b. Underflow
c. Empty element
d. Pop
Ans Underflow
8. When we place book one over the other and then remove,then what type of data structure
Are we using a. Queue
b. Hashing
c. Stack
d. Pop
Ans Stack
9. Handling of interruption is a real time system.so these interruptions are handled in some
order. The order is called a. Last In First Out
b. First Come First Serve
c. Underflow Condition
d. None
Ans First Come First Serve
10. What is Infix Conversion in Stack?
a. When an operator is in-between every pair of operands like 'a' operator 'b'.

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
b. When an operator is followed for every pair of operands like 'a' 'b' operator. c. Both a
and b
d. None
Ans When an operator is in-between every pair of operands like 'a' operator 'b'.
1. What is Postfix Conversion in Stack?
a. When an operator is followed for every pair of operands like 'a' 'b' operator.
b. When an operator is in-between every pair of operands like 'a' operator 'b'.
c. Both a and b
d. None
Ans When an operator is followed for every pair of operands like 'a' 'b' operator.
2. What is Prefix Conversion in Stack?
a. it requires that all operators precedence the two operands that they work on, like + A*B C
b. it requires operator is in between the two operands that it is working on, like A+ B*C
c. it requires that its operators come after the corresponding operands, like A B C*+ d. None
Ans it requires that all operators precedence the two operands that they work on, like +
A*B C
3. What should be done when a left parenthesis `(`occurs in the expression?
a. Placed in the output
b. Placed in the operator stack
c. Ignored
d. a and b ans Placed in the operator stack
4. Time complexity of an infix to postfix conversion algorithm is ?
a. O(n)
b. O(n log n)
c. O(n)
d. None
Ans O(n)
5. Convert the infix expression given below to postfix expression ?
a. a*bc+*de+
b. a+bc*+de*
c. abc++de**
d. abc*+de*+ ans abc*+de*+
6. check which is the correct postfix expression of the following ?
a. a+b*(c^d-e)^(f+g*h)-i
b. abcd^e-fgh*+^*+i-
c. abcd^efgh*+^*+i—
d. abcd^e-fgh*+^*-i+
e. ans abcd^e-fgh*+^*+i-
7. When an operand is read,which of the following is done ?
a. It is ignored
b. It is placed in operator stack
c. It is placed on to the output
d. Operator stack is emptied

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
Ans It is placed on to the output
8. How many stacks are required when using the expression like postfix, infix and prefix?
a. tuning machine needed
b. one stack needed
c. two stack needed
d. many stack needed as per the expression length ans one stack needed
9. Consider the usual algorithm for determining whether a sequence of parentheses is
balanced. The maximum number of parentheses that appear on the stack AT ANY ONE TIME
when the algorithm analyzes: (()())(())) ? a. 3
b. 2
c. 1
d. 4 or more
Ans 3
10. What will be the equivalent infix expression and value for the postfix form 4 2+3*45*- a.
(4*2)+3-(54) and -9
b. (4+4)*3- (2*5) and 4
c. (4+2)3-(45) and -2
d. (4+3)*2-(4*5) and -6
Ans (4+2)3-(45) and -2
1. Which data structure can we use for implementing a recursive algorithm
a. Queue
b. Stack
c. Hash function
d. Tree
Ans Stack
2. What is the worst case time complexity for push operation on a stack
a. O(1)
b. O(log n)
c. O(n)
d. None of the above Ans O(1)
3. Let's do some operation on the stack of size 6.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Push(5);
Push(6);
Pop();
Pop();
after the completion of all operation, the number of elements present in stack are a.
8

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
b. 6
c. 2
d. 1
Ans 1
5. Which data structure is Used to solve the Tower of Hanoi ?
a. Queue
b. Tree
c. Binary search
d. Stack
Ans Stack
7. Entries in a stack are ”ordered”. What is the meaning of this statement ?
a. A collection of stacks is sortable
b. Stack entries may be compared with the ‘<’ operation
c. The entries are stored are in a linked list
d. There is a sequential entry that is one by one
Ans There is a sequential entry that is one by one
8. What is the value of the postfix expression 6 3 2 4 + - * ?
a. 1
b. 40
c. 74
d. -18
Ans -18
9. Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack
algorithm t expression from infix to postfix notation. The maximum number of symbols that
will appear on ONE TIME during the conversion of this expression? a. 1
b. 2
c. 3
d. 4
Ans 4
10. What is the result of the following operation ?
a. X
b. X+S
c. S
d. XS
Ans X
1. List the reason’s for using trees ?
a. Hierarchical
b. No upper limit
c. Quick search and access
d. all
ans all
2. Which is true among the following?

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
a. All the children of a node along with all X the descendants of the children of a node are
known as descendants.
b. All the children of a node along with all the parents of a node are known as descendants.
c. A leaf node has no descendants
d. a and c
ans a and c
3. We can define the degree of a node as :-
a. Number of its edges
b. Number of its parent trees.
c. Number of its sub trees
d. A and b
Ans number of its sub trees
4. Statement 1: The depth of tree starts from 0
Statement 2:the level of tree starts from 1
a. Statement 1 is true and Statement 2 is false
b. Statement 1 is false and Statement 2 is true
c. Both are true
d. Both are false
Ans Both are true
5. A Perfect Binary Tree of height h has:
a. (2h+1-1)nodes (if h starts from 0)
b. (2h-1)nodes (if h starts from 1)
c. (2h+1) nodes (if h starts from 1)
d. a and b
ans a and b
6. In AVL trees, the values of correct balance factor is/are :
a. 1,0
b. 0,-1
c. 1,0,-1
d. Only 1
Ans 1,0,-1
7. The inorder and preorder traversal of a tree is:- H DIBEAFJCKGL and ABDHIECFJGKL Find the
postorder traversal. a. HIDBEJFKLGCA
b. HIDEBJFKLGCA
c. HIDEBKFJLGCA
d. HIDEBJFKGCAB
Ans HIDEBJFKLGCA

8. The balance factor of an AVL tree can be calculated by:-


a. Subtracting the height of the right subtree from the height of the left

subtree

b. Subtracting the height of the left subtree from the height of the right subtree

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here
Capgemini Data Structure 1
c. Either a or b
d. Averaging the height of the left subtree from the height of the right subtree Ans Either a
or b
9. When do we use RR rotation in AVL Trees.
a. when the new node is inserted to the left of the right subtree
b. when the new node is inserted to the O right of the left subtree
c. when the new node is inserted to the right of the right subtree
d. when the new node is inserted to the left of the left subtree
ans when the new node is inserted to the right of the right subtree
10. How many fields do we require for representing an AVL tree ?
a. One
b. Two
c. Three
d. Four
Ans Four 1.

Please Subscribe – youtube.com/@teknouf


Follow us – instagram.com/tekno.uf <= For Any Materials DM here

You might also like