Sei sulla pagina 1di 92

“AtoZ Telugu News”- Mobile App.

✓ పో టీపరీక్షలకు ప్రిప్ేరయ్యే అభ్ేరధులకు "AtoZ Telugu News" App చాలా ఉపయోగపడుత ుంది.
ఈ APP లో పితిరోజు LATEST JOBS, డైలీ Curent Affairs, ఎపపటికపపపడు జరిగే మొతత ుం విదాే
సమాచారాన్ని ఈ APP లో UPDATE చేసత త ఉుంటాము.
✓ ఎపపటికపపపడు మీ చుటటుపకకల జరిగే తాజా వారత లను కూడా చతడవచుు. ఇపపడే మా App ను
Download చేసుక ుండి.

App Link: https://play.google.com/store/apps/details?id=com.app.atoznews


1)Data Structures

Questions and Answers – Array and Array Operations

1. Which of these best describes an array?


a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Container of objects of mixed types
d) All of the mentioned

Answer: b
Explanation: Array contains elements only of the same type.

2. How do you initialize an array in C?


a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);

Answer: c
Explanation: This is the syntax to initialize an array in C.

3. How do you instantiate an array in Java?


a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);

Answer: c
Explanation: Note that option b is declaration whereas option c is to instantiate an array.

4. Which of the following is a correct way to declare a multidimensional array in Java?


a) int[][] arr;
b) int arr[][];
c) int []arr[];
d) All of the mentioned

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: All the options are syntactically correct.

5. What is the output of the following piece of code?


public class array
{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]);
}
}
a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2

Answer: a
Explanation: Array indexing starts from 0.

6. What is the output of the following piece of code?


public class array
{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}
a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException

Answer: c
Explanation: Trying to access an element beyond the limits of an array gives
ArrayIndexOutOfBoundsException.

7. When does the ArrayIndexOutOfBoundsException occur?


a) Compile-time
b) Run-time
c) Not an error
d) None of the mentioned

Answer: b
Explanation: ArrayIndexOutOfBoundsException is a run-time exception and the compilation is
error-free.

8. Which of the following concepts make extensive use of arrays?


a) Binary trees
b) Scheduling of processes
c) Caching

“AtoZ Telugu News –Mobile App”


d) Spatial locality

Answer: d
Explanation: Whenever a particular memory location is referred, it is likely that the locations
nearby are also referred, arrays are stored as contigous blocks in memory, so if you want to
access array elements, spatial locality makes it to access quickly.

9. What are the advantages of arrays?


a) Easier to store elements of same data type
b) Used to implement other data structures like stack and queue
c) Convenient way to represent matrices as a 2D array
d) All of the mentioned

Answer: d
Explanation: Arrays are simple to implement when it comes to matrices of fixed size and type, or
to implement other data structures.

10. What are the disadvantages of arrays?


a) We must know before hand how many elements will be there in the array
b) There are chances of wastage of memory space if elements inserted in an array are lesser
than than the allocated size
c) Insertion and deletion becomes tedious
d) All of the mentioned

Answer: d
Explanation: Arrays are of fixed size, hence during the compile time we should know its size and
type, since arrays are stored in contigous locations, insertion and deletion becomes time
consuming.

11. Assuming int is of 4bytes, what is the size of int arr[15];?


a) 15
b) 19
c) 11
d) 60

Answer: d
Explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.

Data Structure Questions and Answers – Stack Operations – 1

1. Process of inserting an element in stack is called ____________


a) Create
b) Push
c) Evaluation
d) Pop
View Answer
Answer: b
Explanation: None.

2. Process of removing an element from stack is called __________


a) Create
b) Push
c) Evaluation

“AtoZ Telugu News –Mobile App”


d) Pod

Answer: d
Explanation: None.

3. In a stack, if a user tries to remove an element from empty stack it is called _________
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection

Answer: a
Explanation: None.

4. Pushing an element into stack already having five elements and stack size of 5 , then stack
becomes
a) Overflow
b) Crash
c) Underflow
d) User flow

Answer: a
Explanation: None.

5. 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 in a linked list
d) There is a Sequential entry that is one by one

Answer : d
Explanation: None.

6. Which of the following applications may use a stack?


a) A parentheses balancing program
b) Tracking of local variables at run time
c) Compiler Syntax Analyzer
d) All of the mentioned

Answer: d
Explanation: All are applications of stack.

7. 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: (()(())(())) are:
a) 1
b) 2
c) 3
d) 4 or more

Answer: c
Explanation: Applying the postfix expression evaluation.

“AtoZ Telugu News –Mobile App”


8. Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right
parentheses (in some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the
computation?
a) 1
b) 2
c) 3
d) 4 or more

Answer: b
Explanation: Applying the postfix expression evaluation.

9. What is the value of the postfix expression 6 3 2 4 + – *:


a) Something between -5 and -15
b) Something between 5 and -5
c) Something between 5 and 15
d) Something between 15 and 100

Answer: d
Explanation: On solving the postfix expression the answer comes out to 18.

10. Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack
algorithm to convert the expression from infix to postfix notation.
The maximum number of symbols that will appear on the stack AT ONE TIME during the
conversion of this expression?
a) 1
b) 2
c) 3
d) 4

Answer: d
Explanation: None.

Data Structure Questions and Answers – Stack Operations – 2

1. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?


a) AB+ CD*E – FG /**
b) AB + CD* E – F **G /
c) AB + CD* E – *F *G /
d) AB + CDE * – * F *G /

Answer: a
Explanation: Applying the postfix expression evaluation.

2. The data structure required to check whether an expression contains balanced parenthesis is?
a) Stack
b) Queue
c) Array
d) Tree

Answer: a

“AtoZ Telugu News –Mobile App”


3. What data structure would you mostly likely see in a non recursive implementation of a recursive
algorithm?
a) Linked List
b) Stack
c) Queue
d) Tree
View Answer
Answer: b

4. The process of accessing data stored in a serial access memory is similar to manipulating data
on a ________
a) Heap
b) Binary Tree
c) Array
d) Stack

Answer: d.

5. The postfix form of A*B+C/D is?


a) *AB/CD+
b) AB*CD/+
c) A*BC+/D
d) ABCD+/*

Answer: b
Explanation: Applying the postfix expression evaluation.
6. Which data structure is needed to convert infix notation to postfix notation?
a) Branch
b) Tree
c) Queue
d) Stack
View Answer
Answer: d

7. The prefix form of A-B/ (C * D ^ E) is?


a) -/*^ACBDE
b) -ABCD*^DE
c) -A/B*C^DE
d) -A/BC*^DE

Answer: c
Explanation: Applying the prefix expression evaluation.
8. What is the result of the following operation
Top (Push (S, X))
a) X
b) Null
c) S
d) None of the mentioned

Answer: a.
9. The prefix form of an infix expression p + q – r * t is?
a) + pq – *rt
b) – +pqr * t

“AtoZ Telugu News –Mobile App”


c) – +pq * rt
d) – + * pqrt

Answer: c
Explanation: Applying the prefix expression evaluation.
10. Which data structure is used for implementing recursion?
a) Queue
b) Stack
c) Array
d) List

Answer: b
Explanation: Stacks are used for implementation of Recursion.

Data Structure Questions and Answers – Stack Operations – 3

1. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?


a) 600
b) 350
c) 650
d) 588

Answer: b

2. Convert the following infix expressions into its equivalent postfix expressions
(A + B ⋀D)/(E – F)+G
a) (A B D ⋀ + E F – / G +)
b) (A B D +⋀ E F – / G +)
c) (A B D ⋀ + E F/- G +)
d) None of the mentioned

Answer: a
Explanation: Applying the postfix expression evaluation.
3. Convert the following Infix expression to Postfix form using a stack
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.
a) xyz*+pq*r+s*+
b) xyz*+pq*r+s+*
c) xyz+*pq*r+s*+
d) None of the mentioned

Answer: a
Explanation: Applying the postfix expression evaluation.
4. Which of the following statement(s) about stack data structure is/are NOT correct?
a) Linked List are used for implementing Stacks
b) Top of the Stack always contain the new node
c) Stack is the FIFO data structure
d) Null link is present in the last node at the bottom of the stack

Answer: c
Explanation: Stack follows LIFO.
5. Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);

“AtoZ Telugu News –Mobile App”


Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack are
a) 1
b) 2
c) 3
d) 4

Answer: a
Explanation: None.
6. Which of the following is not an inherent application of stack?
a) Reversing a string
b) Evaluation of postfix expression
c) Implementation of recursion
d) Job scheduling

Answer: d
Explanation: Job Scheduling is not performed using stacks.
7. The type of expression in which operator succeeds its operands is?
a) Infix Expression
b) Prefix Expression
c) Postfix Expression
d) None of the mentioned

Answer: c
Explanation: None.
advertisement
8. Assume that the operators +,-, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix
expression a + b X c – d ^ e ^ f is
a) abc X+ def ^^ –
b) abc X+ de^f^ –
c) ab+c Xd – e ^f^
d) -+aXbc^ ^def

Answer: a
Explanation: Applying the postfix expression evaluation.
9. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is
the order of removal?
a) ABCD
b) DCBA
c) DCAB
d) ABDC

Answer: b
Explanation: Stack follows LIFO(Last In First Out).

Queue Operations

“AtoZ Telugu News –Mobile App”


1. A linear list of elements in which deletion can be done from one end (front) and insertion can
take place only at the other end (rear) is known as a ?
a) Queue
b) Stack
c) Tree
d) Linked list

Answer: a

2. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree

Answer: c

3. A queue is a ?
a) FIFO (First In First Out) list
b) LIFO (Last In First Out) list
c) Ordered array
d) Linear tree

Answer: a

4. In Breadth First Search of Graph, which of the following data structure is used?
a) Stack
b) Queue
c) Linked list
d) None of the mentioned
View Answer
Answer: b

5. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what
order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABDC

Answer: a
Explanation: Queue follows FIFO approach.
6. A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue

Answer: c
Explanation: None.
7. A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE

“AtoZ Telugu News –Mobile App”


c) Front = rear + 1
d) Rear = front

Answer: a
Explanation: Condition for size of queue.
advertisement
8. Queues serve major role in
a) Simulation of recursion
b) Simulation of arbitrary linked list
c) Simulation of limited resource allocation
d) All of the mentioned

Answer: c
Explanation: Rest all are implemented using other data structures.
9. Which of the following is not the type of queue?
a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue

Answer: b
Explanation: Queue always has two ends.

Singly Linked List Operations – 1

1. A linear collection of data elements where the linear node is given by means of pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) None of the mentioned

Answer: a

2. Consider an implementation of unsorted singly linked list. Suppose it has its representation with
a head pointer only.
Given the representation, which of the following operation can be implemented in O(1) time?
i) Insertion at the front of the linked list
ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list
a) I and II
b) I and III
c) I, II and III
d) I, II and IV

Answer: b

3. In linked list each node contain minimum of two fields. One field is data field to store the data
second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node

“AtoZ Telugu News –Mobile App”


Answer: c
Explanation: None.
4. What would be the asymptotic time complexity to add a node at the end of singly linked list, if the
pointer is initially pointing to the head of the list?
a) O(1)
b) O(n)
c) θ(n)
d) θ(1)

Answer: c

5. What would be the asymptotic time complexity to add an element in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) None of the mentioned
View Answer
Answer: b
.
6. What would be the asymptotic time complexity to find an element in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) None of the mentioned

Answer: b

7. What would be the asymptotic time complexity to insert an element at the second position in the
linked list?
a) O(1)
b) O(n)
c) O(n2)
d) None of the mentioned

Answer: a

8. The concatenation of two list can performed in O(1) time. Which of the following variation of
linked list can be used?
a) Singly linked list
b) Doubly linked list
c) Circular doubly linked list
d) Array implementation of list

Answer: c

9. Consider the following definition in c programming language


struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;

“AtoZ Telugu News –Mobile App”


Which of the following c code is used to create new node?
a) ptr = (NODE*)malloc(sizeof(NODE));
b) ptr = (NODE*)malloc(NODE);
c) ptr = (NODE*)malloc(sizeof(NODE*));
d) ptr = (NODE)malloc(sizeof(NODE));

Answer: a
Explanation: As it represents the right way to create a node.

Singly Linked List Operations – 2

1. What kind of linked list is best to answer question like “What is the item at position n?”
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) Array implementation of linked list

Answer: d
Explanation: None.
2. Linked lists are not suitable to for the implementation of?
a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search

Answer: d
Explanation: It cannot be implemented using linked lists.
3. Linked list is considered as an example of ___________ type of memory allocation.
a) Dynamic
b) Static
c) Compile time
d) None of the mentioned

Answer: a
Explanation: As memory is allocated at the run time.
4. In Linked List implementation, a node carries information regarding
a) Data
b) Link
c) Data and Link
d) None of the mentioned

Answer: b
Explanation: None.
5. Linked list data structure offers considerable saving in
a) Computational Time
b) Space Utilization
c) Space Utilization and Computational Time
d) None of the mentioned

Answer: c
Explanation: Linked lists saves both space and time.

“AtoZ Telugu News –Mobile App”


6. Which of the following points is/are true about Linked List data structure when it is compared
with array
a) Arrays have better cache locality that can make them better in terms of performance
b) It is easy to insert and delete elements in Linked List
c) Random access is not allowed in a typical implementation of Linked Lists
d) All of the mentioned

Answer: d
Explanation: None.
7. What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
a) Prints all nodes of linked lists
b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order

Answer: b
Explanation: fun1() prints the given Linked List in reverse manner.
For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.
8. Which of the following sorting algorithms can be used to sort a random linked list with minimum
time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort

Answer: d
Explanation: Both Merge sort and Insertion sort can be used for linked lists. The slow random-
access performance of a linked list makes other algorithms (such as quicksort) perform poorly,
and others (such as heapsort) completely impossible. Since worst case time complexity of
Merge Sort is O(nLogn) and Insertion sort is O(n2), merge sort is preferred.

Singly Linked List

1. Which of the following is not a disadvantage to the usage of array?


a) Fixed size
b) You know the size of the array prior to allocation
c) Insertion based on position
d) Accessing elements at specified positions
Answer: d
Explanation: Array elements can be accessed in two steps. First, multiply the size of the data
type with the specified position, second, add this value to the base address. Both of these
operations can be done in constant time, hence accessing elements at a given index/position is
faster.
2. What is the time complexity of inserting at the end in dynamic arrays?
a) O(1)
b) O(n)
“AtoZ Telugu News –Mobile App”
c) O(logn)
d) Either O(1) or O(n)

Answer: d
Explanation: Depending on whether the array is full or not, the complexity in dynamic array
varies. If you try to insert into an array which is not full, then the element is simply stored at the
end, this takes O(1) time. If you try to insert into an array which is full, first you will have to
allocate an array with double the size of the current array and then copy all the elements into it
and finally insert the new element, this takes O(n) time.
3. What is the time complexity to count the number of elements in the linked list?
a) O(1)
b) O(n)
c) O(logn)
d) None of the mentioned

Answer: b
Explanation: To count the number of elements, you have to traverse through the entire list,
hence complexity is O(n).

4. What is the space complexity for deleting a linked list?


a) O(1)
b) O(n)
c) Either O(1) or O(n)
d) O(logn)

Answer: a
Explanation: You need a temp variable to keep track of current node, hence the space
complexity is O(1).

Doubly Linked List

1. Which of the following is false about a doubly linked list?


a) We can navigate in both the directions
b) It requires more space than a singly linked list
c) The insertion and deletion of a node take a bit longer
d) None of the mentioned

Answer: d
Explanation: A doubly linked list has two pointers ‘left’ and ‘right’ which enable it to traverse in
either direction. Compared to singly liked list which has only a ‘next’ pointer, doubly linked list
requires extra space to store this extra pointer. Every insertion and deletion requires
manipulation of two pointers, hence it takes a bit longer time.

3. What is a memory efficient double linked list?


a) Each node has only one pointer to traverse the list back and forth
b) The list has breakpoints for faster traversal
c) An auxiliary singly linked list acts as a helper list to traverse through the doubly linked list
d) None of the mentioned

Answer: a
Explanation: Memory efficient doubly linked list has been proposed recently which has only one
pointer to traverse the list back and forth. The implementation is based on pointer difference.

– Circular Linked List

“AtoZ Telugu News –Mobile App”


1. What differentiates a circular linked list from a normal linked list?
a) You cannot have the ‘next’ pointer point to null in a circular linked list
b) It is faster to traverse the circular linked list
c) You may or may not have the ‘next’ pointer point to null in a circular linked list
d) All of the mentioned

Answer: c
Explanation: The ‘next’ pointer points to null only when the list is empty, otherwise it points to
the head of the list.

4. What is the time complexity of searching for an element in a circular linked list?
a) O(n)
b) O(nlogn)
c) O(1)
d) None of the mentioned

Answer: a
Explanation: In the worst case, you have to traverse through the entire list of n elements.
5. Which of the following application makes use of a circular linked list?
a) Undo operation in a text editor
b) Recursive function calls
c) Allocating CPU to resources
d) All of the mentioned

Answer: c
Explanation: Generally, round robin fashion is employed to allocate CPU time to resources
which makes use of the circular linked list data structure.

9. Which of the following is false about a circular linked list?


a) Every node has a successor
b) Time complexity of inserting a new node at the head of the list is O(1)
c) Time complexity for deleting the last node is O(n)
d) None of the mentioned

Answer: b
Explanation: Time complexity of inserting a new node at the head of the list is O(n) because you
have to traverse through the list to find the tail node.
10. Consider a small circular linked list. How to detect the presence of cycles in this list effectively?
a) Keep one node as head and traverse another temp node till the end to check if its ‘next points
to head
b) Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow
pointer advancing by one node at a time
c) Cannot determine, you have to pre-define if the list contains cycles
d) None of the mentioned

Answer: b
Explanation: Advance the pointers as mentioned in ‘b’, check to see if at any given instant of
time if the fast pointer points to slow pointer or if the fast pointer’s ‘next’ points to the slow
pointer. Note that this trick is useful only if the list is small.

Data Structure Questions and Answers – Bit Array

“AtoZ Telugu News –Mobile App”


1. What is a bit array?
a) Data structure for representing arrays of records
b) Data structure that compactly stores bits
c) An array in which most of the elements have the same value
d) None of the mentioned

Answer: b
Explanation: It compactly stores bits and exploits bit-level parallelism.
2. Which of the following bitwise operations will you use to set a particular bit to 1?
a) OR
b) AND
c) XOR
d) NOR

Answer: a
Explanation: 1 OR 1 = 1, 0 OR 1 = 1, any bit OR’ed with 1 gives 1.
3. Which of the following bitwise operations will you use to set a particular bit to 0?
a) OR
b) AND
c) XOR
d) NAND

Answer: b
Explanation: 1 AND 0 = 0, 0 AND 0 = 0, any bit AND with 0 gives 0.
4. Which of the following bitwise operations will you use to toggle a particular bit?
a) OR
b) AND
c) XOR
d) NOT

Answer: c
Explanation: 1 XOR 1 = 0, 0 XOR 1 = 1, note that NOT inverts all the bits, while XOR toggles
only a specified bit.
5. Which of the following is an advantage of bit array?
a) Exploit bit level parallelism
b) Maximal use of data cache
c) Can be stored and manipulated in the register set for long periods of time
d) All of the mentioned

Answer: d
Explanation: Because bit arrays are compact, they outperform many other data structures.
6. Identify the disadvantages of bit array.
a) Without compression, they might become sparse
b) Accessing individual bits is expensive
c) Compressing bit array to byte/word array, the machine also has to support byte/word
addressing
d) All of the mentioned

Answer: d
Explanation: Without compression, they become sparse in both time and space, also if random
access is more common than sequential access, then they have to be compressed to byte/word
array.
7. What are some of the applications of bit arrays?
a) Used by the Linux kernel

“AtoZ Telugu News –Mobile App”


b) For the allocation of memory pages
c) Bloom filter
d) All of the mentioned

Answer: d
Explanation: Used in priority queues data structure in the Linux kernel, for allocation of memory
pages, a bitmap is used.
advertisement
8. Which class in Java can be used to represent bit array?
a) BitSet
b) BitVector
c) BitArray
d) BitStream

Answer: a
Explanation: The BitSet class creates a special type of array that can hold bit values.

Data Structure Questions and Answers – Binary Trees using Array

1. Binary trees can have how many children?


a) 2
b) any number of children
c) 0 or 1 or 2
d) 0 or 1

Answer: c
Explanation: Can have atmost 2 nodes.
2. Disadvantage of using array representation for binary trees is?
a) difficulty in knowing children nodes of a node
b) difficult in finding the parent of a node
c) have to know the maximum number of nodes possible before creation of trees
d) difficult to implement

Answer: c
Explanation: The array is fixed size (may be dynamic array or static array) but size is fixed.
3. What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l

Answer: a
Explanation: Since maximum elements in a tree (complete binary tree) of height l will be 2 l-1 so
a good array size must be that (since a binary tree node may not always have 2 children but for
safety a is correct).
4. What are the children for node ‘w’ of a complete-binary tree in an array representation?
a) 2w and 2w+1
b) 2+w and 2-w
c) w+1/2 and w/2
d) w-1/2 and w+1/2

Answer: a
Explanation: Since each node has 2 children and so counting from beginning, a particular node
will have children as option a.

“AtoZ Telugu News –Mobile App”


5. What is the parent for a node ‘w’ of a complete binary tree in an array representation when w is
not 0?
a) floor(w-1/2)
b) ceil(w-1/2)
c) w-1/2
d) w/2

Answer: a
Explanation: Floor of w-1/2 because we can’t miss a node.
6. If the tree is not a complete binary tree then what changes can be made for easy access of
children of a node in the array ?
a) every node stores data saying which of its children exist in the array
b) no need of any changes continue with 2w and 2w+1, if node is at i
c) keep a seperate table telling children of a node
d) use another array parallel to the array with tree

Answer: a
Explanation: Array cannot represent arbitrary shaped trees it can only be used in case of
complete trees hence option a must be done which is one of several ways to use array in such
situations.

8. Consider a situation of writing a binary tree into a file with memory storage efficiency in mind, is
array representation of tree is good?
a) yes because we are overcoming the need of pointers and so space efficiency
b) yes because array values are indexable
c) No it is not efficient in case of sparse trees and remaning cases it is fine
d) No linked list representation of tree is only fine

Answer: c
Explanation: In case of sparse trees(where one node per level in worst cases), the array size
(2h)-1 where h is height but only h indexes will be filled and (2 h)-1-h nodes will be left unused
leading to space wastage which was actually main theme of question.

10. Can a tree stored in an array using either one of inorder or post order or pre order traversals be
again reformed?
a) yes just traverse through the array and form the tree
b) No we need one more traversal to form a tree
c) No in case of sparse trees
d) None of the mentioned
View Answer
Answer: b
Explanation: We need any two traversals for tree formation but if some additional stuff or
techniques are used while storing a tree in an array then one traversal can facilitate like also
storing null values of a node in array.

Binary Trees using Linked Lists

1. Advantages of linked list representation of binary trees over arrays?


a) dynamic size
b) ease of insertion/deletion
c) ease in randomly accessing a node

“AtoZ Telugu News –Mobile App”


d) both dynamic size and ease in insertion/deletion

Answer: d
Explanation: It has both dynamic size and ease in insertion and deletion as advantages.
2. Disadvantages of linked list representation of binary trees over arrays?
a) Randomly accessing is not possible
b) Extra memory for a pointer is needed with every element in the list
c) Difficulty in deletion
d) Random access is not possible and extra memory with every element

Answer: d
Explanation: Random access is not possible with linked lists.
3. How to travel a tree in linkedlist representation?
a) using post order traversing
b) using pre order traversing
c) using post order traversing
d) all of the mentioned

Answer: d
Explanation: Also level order traversing is possible.
4. Level order traversal of a tree is formed with the help of
a) breadth first search
b) depth first search
c) dijkstra’s algorithm
d) prims algorithm

Answer: a
Explanation: Level order is similar to bfs.
5. Why we prefer threaded binary trees?
a) storage required by stack and queue is more
b) pointers in most of nodes of a binary tree are NULL
c) difficult to find a successor node
d) all of the mentioned

Answer: d
Explanation: All the given options are properties for a threaded tree.
6. The following lines talks about deleting a node in a binary tree.(the tree property must not be
violated after deletion)
i) from root search for the node to be deleted
ii)
iii) delete the node at
what must be statement ii) and fill up statement iii)
a) ii)-find random node,replace with node to be deleted. iii)- delete the node
b) ii)-find node to be deleted. iii)- delete the node at found location
c) ii)-find deepest node,replace with node to be deleted. iii)- delete a node
d) ii)-find deepest node,replace with node to be deleted. iii)- delete the deepest node

Answer: d
Explanation: We just replace a to be deleted node with last leaf node of a tree. this must not be
done in case of BST or heaps.
7. What may be the psuedo code for finding the size of a tree?
a) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)
b) find_size(root_node–>left_node) + find_size(root_node–>right_node)
c) find_size(root_node–>right_node) – 1

“AtoZ Telugu News –Mobile App”


d) find_size(root_node–>left_node + 1

Answer: a
Explanation: Draw a tree and analyze the expression. we are always taking size of left subtree
and right subtree and adding root value(1) to it and finally printing size.

Binary Tree Operations Multiple Choice Questions and Answers (MCQs)

1. What is the maximum number of children that a binary tree node can have?
a) 0
b) 1
c) 2
d) 3

Answer: c
Explanation: In a binary tree, a node can have atmost 2 nodes (i.e.) 0,1 or 2 left and right child.
2. The following given tree is an example for?

a) Binary tree
b) Binary search tree
c) Fibonacci tree
d) AVL tree
Answer: b
Explanation: The given tree is an example for binary search since the tree has got two children
and the left and right children do not satisfy binary search tree’s property.
3. A binary tree is a rooted tree but not an ordered tree.
a) true
b) false

Answer: b
Explanation: A binary tree is a rooted tree and also an ordered tree (i.e) every node in a binary
tree has at most two children.
4. How many common operations are performed in a binary tree?
a) 1
b) 2
c) 3
d) 4

Answer: c
Explanation: Three common operations are performed in a binary tree- they are insertion,
deletion and traversal.
5. What is the traversal strategy used in the binary tree?
a) depth-first traversal
b) breadth-first traversal
c) random traversal
d) preorder traversal

“AtoZ Telugu News –Mobile App”


Answer: b
Explanation: Breadth first traversal, also known as level order traversal is the traversal strategy
used in a binary tree. It involves visiting all the nodes at a given level.
6. How many types of insertion are performed in a binary tree?
a) 1
b) 2
c) 3
d) 4

Answer: b
Explanation: Two kinds of insertion operation is performed in a binary tree- inserting a leaf node
and inserting an internal node.
7. What operation does the following diagram depict?

a) inserting a leaf node


b) inserting an internal node
c) deleting a node with 0 or 1 child
d) deleting a node with 2 children

Answer: c
Explanation: The above diagram is a depiction of deleting a node with 0 or 1 child since the
node D which has 1 child is deleted.
8. General ordered tree can be encoded into binary trees.
a) true
b) false
View Answer
Answer: a
Explanation: General ordered tree can be mapped into binary tree by representing them in a
left-child-right-sibling way.
9. How many bits would a succinct binary tree occupy?
a) n+O(n)
b) 2n+O(n)
c) n/2
d) n

Answer: b
Explanation: A succinct binary tree occupies close to minimum possible space established by
lower bounds. A succinct binary tree would occupy 2n+O(n) bits.
10. The average depth of a binary tree is given as?
a) O(N)
b) O(√N)
c) O(N2)
d) O(log N)

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: The average depth of a binary tree is given as O(√N). In case of a binary search
tree, it is O(log N).

– Preorder Traversal

1. For the tree below, write the pre-order traversal.


a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9

Answer: a
Explanation: Pre order traversal follows NLR(Node-Left-Right).
2. For the tree below, write the post-order traversal.
a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9

Answer: c
Explanation: Post order traversal follows LRN(Left-Right-Node).
7. What is the time complexity of pre-order traversal in the iterative fashion?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)

Answer: b
Explanation: Since you have to go through all the nodes, the complexity becomes O(n).
8. What is the space complexity of the post-order traversal in the recursive fashion? (d is the tree
depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
View Answer
Answer: d
Explanation: In the worst case we have d stack frames in the recursive call, hence the
complexity is O(d).
9. To obtain a prefix expression, which of the tree traversals is used?
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal

Answer: b
Explanation: As the name itself suggests, pre-order traversal can be used.

Postorder Traversal Multiple Choice Questions and Answers (MCQs)

“AtoZ Telugu News –Mobile App”


1. In postorder traversal of binary tree right subtree is traversed before visiting root.
a) True
b) False

Answer: a
Explanation: Post-order method of traversing involves – i) Traverse left subtree in post-order, ii)
Traverse right subtree in post-order, iii) visit the root.
2. What is the possible number of binary trees that can be created with 3 nodes, giving the
sequence N, M, L when traversed in post-order.
a) 15
b) 3
c) 5
d) 8

Answer: c
Explanation: 5 binary trees are possible and they are,

3. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal will
be ________
a) T Q R S O P
b) T O Q R P S
c) T Q O P S R
d) T Q O S P R

Answer: c
Explanation: The last, second last nodes visited in post-order traversal are root and it’s right
child respectively. Option T Q R S O P can’t be a pre-order traversal, because nodes O, P are
visited after the nodes Q, R, S. Option T O Q R P S, can’t be valid, because the pre-order
sequence given in option T O Q R P S and given post-order traversal creates a tree with node T
as root and node O as left subtree. Option T Q O P S R is valid. Option T Q O S P R is not valid
as node P is visited after visiting node S.
4. A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a
valid post-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70,
40 and 75?
a) 7, 8, 26, 13, 75, 40, 70, 35
b) 26, 13, 7, 8, 70, 75, 40, 35
c) 7, 8, 13, 26, 35, 40, 70, 75
d) 8, 7, 26, 13, 40, 75, 70, 35

Answer: d
Explanation: The binary tree contains values 7, 8, 13, 26, 35, 40, 70, 75. The given pre-order
sequence is 35, 13, 7, 8, 26, 70, 40 and 75. So, the binary search tree formed is

“AtoZ Telugu News –Mobile App”


Thus post-order sequence for the tree is 8, 7, 26, 13, 40, 75, 70 and 35.
5. Which of the following pair’s traversals on a binary tree can build the tree uniquely?
a) post-order and pre-order
b) post-order and in-order
c) post-order and level order
d) level order and preorder

Answer: b
Explanation: A binary tree can uniquely be created by post-order and in-order traversals.
6. A full binary tree can be generated using ______
a) post-order and pre-order traversal
b) pre-order traversal
c) post-order traversal
d) in-order traversal

Answer: a
Explanation: Every node in a full binary tree has either 0 or 2 children. A binary tree can be
generated by two traversals if one of them is in-order. But, we can generate a full binary tree
using post-order and pre-order traversals.
7. The maximum number of nodes in a tree for which post-order and pre-order traversals may be
equal is ______
a) 3
b) 1
c) 2
d) any number
View Answer
Answer: b
Explanation: The tree with only one node has post-order and pre-order traversals equal.
8. The steps for finding post-order traversal are traverse the right subtree, traverse the left subtree
or visit the current node.
a) True
b) False
View Answer
Answer: b
Explanation: Left subtree is traversed first in post-order traversal, then the right subtree is
traversed and then the output current node.
9. The pre-order and in-order are traversals of a binary tree are T M L N P O Q and L M N T O P
Q. Which of following is post-order traversal of the tree?
a) L N M O Q P T
b) N M O P O L T
c) L M N O P Q T
d) O P L M N Q T
View Answer
“AtoZ Telugu News –Mobile App”
Answer: a
Explanation: The tree generated by using given pre-order and in-order traversal is

Thus, L N M O Q P T will be the post-order traversal.


10. For a binary tree the first node visited in in-order and post-order traversal is same.
a) True
b) False
View Answer
Answer: b
Explanation: Consider a binary tree,

Its in-order traversal – 13 14 16 19


Its post-order traversal- 14 13 19 16. Here the first node visited is not same.

Data Structure Questions and Answers – Inorder Traversal

1. For the tree below, write the in-order traversal.


a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
View Answer
Answer: d
Explanation: In-order traversal follows LNR(Left-Node-Right).
2. For the tree below, write the level-order traversal.
a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
View Answer
Answer: b
Explanation: Level order traversal follows a breadth first search approach.
5. What is the space complexity of the in-order traversal in the recursive fashion? (d is the tree
depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
View Answer

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: In the worst case we have d stack frames in the recursive call, hence the
complexity is O(d).
6. What is the time complexity of level order traversal?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
View Answer
Answer: b
Explanation: Since you have to go through all the nodes, the complexity becomes O(n).
7. Which of the following graph traversals closely imitates level order traversal of a binary tree?
a) Depth First Search
b) Breadth First Search
c) Depth & Breadth First Search
d) None of the mentioned
View Answer
Answer: b
Explanation: Both level order tree traversal and breadth first graph traversal follow the principle
that visit your neighbors first and then move on to further nodes.
8. In a binary search tree, which of the following traversals would print the numbers in the
ascending order?
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
View Answer
Answer: d
Explanation: In a binary search tree, a node’s left child is always lesser than the node and right
child is greater than the node, hence an in-order traversal would print them in a non decreasing
fashion.

– Binary Tree Properties

1. The number of edges from the root to the node is called __________ of the tree.
a) Height
b) Depth
c) Length
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
2. The number of edges from the node to the deepest leaf is called _________ of the tree.
a) Height
b) Depth
c) Length
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
3. What is a full binary tree?
a) Each node has exactly zero or two children
b) Each node has exactly two children
c) All the leaves are at the same level

“AtoZ Telugu News –Mobile App”


d) Each node has exactly one or two children
View Answer
Answer: a
Explanation: None.
4. What is a complete binary tree?
a) Each node has exactly zero or two children
b) A binary tree, which is completely filled, with the possible exception of the bottom level, which
is filled from right to left
c) A binary tree, which is completely filled, with the possible exception of the bottom level, which
is filled from left to right
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
5. What is the time complexity for finding the height of the binary tree?
a) h = O(loglogn)
b) h = O(nlogn)
c) h = O(n)
d) h = O(log n)
View Answer
Answer: d
Explanation: The nodes are either a part of left sub tree or the right sub tree, so we don’t have
to traverse all the nodes, this means the complexity is lesser than n, in the average case,
assuming the nodes are spread evenly, the time complexity becomes O(n).
6. Which of the following is not an advantage of trees?
a) Hierarchical structure
b) Faster search
c) Router algorithms
d) Undo/Redo operations in a notepad
View Answer
Answer: d
Explanation: This is an application of stack.
7. In a full binary tree if number of internal nodes is I, then number of leaves L are?
a) L = 2I
b) L = I + 1
c) L = I – 1
d) L = 2I – 1
View Answer
Answer: b
Explanation: None.
8. In a full binary tree if number of internal nodes is I, then number of nodes N are?
a) N = 2I
b) N = I + 1
c) N = I – 1
d) N = 2I + 1
View Answer
Answer: d
Explanation: None.
9. In a full binary tree if there are L leaves, then total number of nodes N are?
a) N = 2L
b) N = L + 1
c) N = L – 1
d) N = 2L – 1
View Answer

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: None.
10. Which of the following is correct with respect to binary trees?
a) Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level k
b) Let T be a binary tree with λ levels. Then T has no more than 2 λ – 1 nodes
c) Let T be a binary tree with N nodes. Then the number of levels is at least ceil(log (N + 1))
d) All of the mentioned
View Answer
Answer: d
Explanation: None.

Undirected Graph

1. The number of possible undirected graphs which may have self loops but no multiple edges and
have n vertices is ________
a) 2((n*(n-1))/2)
b) 2((n*(n+1))/2)
c) 2((n-1)*(n-1))/2)
d) 2((n*n)/2)
View Answer
Answer: d
Explanation: There can be at most, n*n edges in an undirected graph.
2. Given a plane graph, G having 2 connected component, having 6 vertices, 7 edges and 4
regions. What will be the number of connected components?
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: b
Explanation: Euler’s Identity says V – E + R = 1+ number of connected components.
3. Number of vertices with odd degrees in a graph having a eulerian walk is ________
a) 0
b) Can’t be predicted
c) 2
d) either 0 or 2
View Answer
Answer: d
Explanation: If the start and end vertices for the path are same the answer would be 0 otherwise
2.
4. How many of the following statements are correct?
i) All cyclic graphs are complete graphs.
ii) All complete graphs are cyclic graphs.
iii) All paths are bipartite.
iv) All cyclic graphs are bipartite.
v) There are cyclic graphs which are complete.
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: b
Explanation: Statements iii) and v) are correct.

“AtoZ Telugu News –Mobile App”


5. All paths and cyclic graphs are bipartite graphs.
a) True
b) False
View Answer
Answer: b
Explanation: Only paths and even cycles are bipartite graphs.
6. What is the number of vertices of degree 2 in a path graph having n vertices,here n>2.
a) n-2
b) n
c) 2
d) 0
View Answer
Answer: a
Explanation: Only the first and the last vertex would have degree 1, others would be of degree
2.
7. All trees with n vertices consists of n-1 edges.
a) True
b) False
View Answer
Answer: a
Explanation: A trees is acyclic in nature.
8. Which of the following graphs are isomorphic to each other?

a) fig 1 and fig 2


b) fig 2 and fig 3
c) fig 1 and fig 3
d) fig 1, fig 2 and fig 3
View Answer
Answer: d
Explanation: All three graphs are Complete graphs with 4 vertices.

“AtoZ Telugu News –Mobile App”


9. In the given graph which edge should be removed to make it a Bipartite Graph?

a) A-C
b) B-E
c) C-D
d) D-E
View Answer
Answer: a
Explanation: The resultant graph would be a Bipartite Graph having {A,C,E} and {D, B} as its
subgroups.
10. What would the time complexity to check if an undirected graph with V vertices and E edges is
Bipartite or not given its adjacency matrix?
a) O(E*E)
b) O(V*V)
c) O(E)
d) O(V)
View Answer
Answer: b
Explanation: A graph can be checked for being Bipartite by seeing if it is 2-colorable or not,
which can be obtained with the help of BFS.

Data Structure Questions and Answers – Directed Graph

1. Dijkstra’s Algorithm will work for both negative and positive weights?
a) True
b) False
View Answer
Answer: b
Explanation: Dijkstra’s Algorithm assumes all weights to be non-negative.
2. A graph having an edge from each vertex to every other vertex is called a ___________
a) Tightly Connected
b) Strongly Connected
c) Weakly Connected
d) Loosely Connected
View Answer
Answer: a
Explanation: This is a part of the nomenclature followed in Graph Theory.
3. What is the number of unlabeled simple directed graph that can be made with 1 or 2 vertices?
a) 2
b) 4
c) 5

“AtoZ Telugu News –Mobile App”


d) 9
View Answer
Answer: b

Explanation:
4. Floyd Warshall Algorithm used to solve the shortest path problem has a time complexity of
__________
a) O(V*V)
b) O(V*V*V)
c) O(E*V)
d) O(E*E)
View Answer
Answer: b
Explanation: The Algorithm uses Dynamic Programming and checks for every possible path.
5. All Graphs have unique representation on paper.
a) True
b) False
View Answer
Answer: b
Explanation: Same Graph may be drawn in different ways on paper.
6. Assuming value of every weight to be greater than 10, in which of the following cases the
shortest path of a directed weighted graph from 2 vertices u and v will never change?
a) add all values by 10
b) subtract 10 from all the values
c) multiply all values by 10
d) in both the cases of multiplying and adding by 10
View Answer
Answer: c
Explanation: In case of addition or subtraction the shortest path may change because the
number of edges between different paths may be different, while in case of multiplication path
wont change.
7. What is the maximum possible number of edges in a directed graph with no self loops having 8
vertices?
a) 28
b) 64
c) 256
d) 56
View Answer
Answer: d
Explanation: If a graph has V vertices than every vertex can be connected to a possible of V-1
vertices.

“AtoZ Telugu News –Mobile App”


8. What would be the DFS traversal of the given Graph?

a) ABCED
b) AEDCB
c) EDCBA
d) ADECB
View Answer
Answer: a
Explanation: In this case two answers are possible including ADEBC.

10. What is the maximum number of edges present in a simple directed graph with 7 vertices if
there exists no cycles in the graph?
a) 21
b) 7
c) 6
d) 49
View Answer
Answer: c
Explanation: If the no cycles exists then the difference between the number of vertices and
edges is 1.

Data Structure Questions and Answers – Directed Acyclic Graph

1. Every Directed Acyclic Graph has at least one sink vertex.


a) True
b) False
View Answer
Answer: a
Explanation: A sink vertex is a vertex which has an outgoing degree of zero.
2. Which of the following is a topological sorting of the given graph?

a) A B C D E F
b) A B F E D C
“AtoZ Telugu News –Mobile App”
c) A B E C F D
d) All of the Mentioned
View Answer
Answer: d
Explanation: Topological sorting is a linear arrangement of vertices such that for every directed
edge uv from vertex u to vertex v, u comes before v in the ordering.
3. With V(greater than 1) vertices, how many edges at most can a Directed Acyclic Graph
possess?
a) (V*(V-1))/2
b) (V*(V+1))/2
c) (V+1)C2
d) (V-1)C2
View Answer
Answer: a
Explanation: The first edge would have an outgoing degree of atmost V-1, the next edge would
have V-2 and so on, hence V-1 + V-2…. +1 equals (V*(V-1))/2.
4. The topological sorting of any DAG can be done in ________ time.
a) cubic
b) quadratic
c) linear
d) logarithmic
View Answer
Answer: c
Explanation: Topological sorting can be done in O(V+E), here V and E represents number of
vertices and number of edges respectively.
5. If there are more than 1 topological sorting of a DAG is possible, which of the following is true.
a) Many Hamiltonian paths are possible
b) No Hamiltonian path is possible
c) Exactly 1 Hamiltonian path is possible
d) Given information is insufficient to comment anything
View Answer
Answer: b
Explanation: For a Hamiltonian path to exist all the vertices must be connected with a path, had
that happened there would have been a unique topological sort.
6. What sequence would the BFS traversal of the given graph yield?

a) A F D B C E
b) C B A F D
c) A B D C F
d) F D C B A
View Answer
Answer: c
Explanation: In BFS nodes gets explored and then the neighbors of the current node gets
explored, before moving on to the next levels.
“AtoZ Telugu News –Mobile App”
Data Structure Questions and Answers – Propositional and Directed Acyclic Word Graph

1. In which of the following does a Directed Acyclic Word Graph finds its application in?
a) String Matching
b) Number Sorting
c) Manipulations on numbers
d) None of the mentioned
View Answer
Answer: a
Explanation: A Directed Acyclic Word Graph is similar to suffix tree, it can be viewed as a
Deterministic Finite Automata.
Answer the following questions(2-3) for the given DWAG.

2. What is the number of words that can be formed from the given Directed Acyclic Word
Graph?
a) 2
b) 4
c) 12
d) 7
View Answer
Answer: b
Explanation: Words namely BATS, BOTS, BAT and BOT can be formed.
3. Determine the longest string which is described by the given Directed Acyclic Word Graph.
a) BATS
b) BOATS
c) BOT
d) None of the mentioned
View Answer
Answer: a
Explanation: Starting from the initial state and choosing B, A, T, S respectively.
4. What is time complexity to check if a string(length S1) is a substring of another string(length S2)
stored in a Directed Acyclic Word Graph, given S2 is greater than S1?
a) O(S1)
b) O(S2)
c) O(S1+S2)

“AtoZ Telugu News –Mobile App”


d) O(1)
View Answer
Answer: a
Explanation: For each check of a word of length S1, we need to follow at most S1 edges.
5. In which of the following case does a Propositional Directed Acyclic Graph is used for?
a) Representation of Boolean Functions
b) String Matching
c) Searching
d) Sorting of number
View Answer
Answer: a
Explanation: A Propositional Directed Acyclic Graph is used to represent a boolean function.
For the given symbols answer the following questions.
i) Δ
ii) ◊
iii) ∇
iv) T
v) ⊥
6. Which of the given symbols represent nodes having at least one child?
a) iv) and v)
b) iii) iv) and v)
c) i) and ii)
d) i) and iii)
View Answer
Answer: c
Explanation: The two symbols represent logical AND and OR gates.
7. Which of the given symbols represent nodes having exactly one child?
a) iv) and v)
b) v)
c) i) and iii)
d) ii)
View Answer
Answer: d
Explanation: This symbol represents the logical NOT gate.
8. Which of the given symbols represent may represent leaf nodes?
a) iv) and v)
b) v)
c) i) and iii)
d) ii)
View Answer
Answer: a
Explanation: The two symbols represent the Boolean values.
9. Every Binary Decision Diagram is also a Propositional Directed Acyclic Graph.
a) True
b) False
View Answer
Answer: a
Answer: Both Binary Decision Diagram and Propositional Directed Acyclic Graph may be used
to represent the same Boolean function.
advertisement
10. In a Propositional Directed Acyclic Graph Leaves maybe labelled with a boolean variable.
a) True
b) False
View Answer

“AtoZ Telugu News –Mobile App”


Answer: a
Explanation: In a Propositional Directed Acyclic Graph leaves maybe labelled with a boolean
variable, T or ⊥.

Data Structure Questions and Answers – Multigraph and Hypergraph

1. Given Adjacency matrices determine which of them are PseudoGraphs?


i) {{1,0} {0,1}}
ii) {{0,1}{1,0}}
iii) {{0,0,1}{0,1,0}{1,0,0}}
a) only i)
b) ii) and iii)
c) i) and iii)
d) i) ii) and iii)
View Answer
Answer: c
Explanation: In i) self loops exist for both the vertices, in iii) self loop exists in the second vertex.
2. All undirected Multigraphs contain eulerian cycles.
a) True
b) False
View Answer
Answer: a
Explanation: Only graphs with every vertex having even degree have eulerian circuits or cycles.
3. Determine the number of vertices for the given Graph or Multigraph?
G is a 4-regular Graph having 12 edges.
a) 3
b) 6
c) 4
d) Information given is insufficient
View Answer
Answer: b
Explanation: Sum of degrees of all the edges equal to 2 times the number of edges. 2*12=4*n,
n=>6.
4. Which of the following statement is true.
a) There exists a Simple Graph having 10 vertices such that minimum degree of the graph is 0
and maximum degree is 9
b) There exists a MultiGraph having 10 vertices such that minimum degree of the graph is 0 and
maximum degree is 9
c) There exists a MultiGraph as well as a Simple Graph having 10 vertices such that minimum
degree of the graph is 0 and maximum degree is 9
d) None of the mentioned
View Answer
Answer: b
Explanation: If a vertex has a degree 9 that means it is connected to all the other vertices, in
case of Multigraphs for an isolate vertex, and a multiple edge may compensate.
5. Given Adjacency matrices determine which of them are PseudoGraphs?
i) {{1,0} {0,1}}
ii) {{0,1}{1,0}}
iii) {{0,0,1}{0,1,0}{1,0,0}}
a) only i)
b) ii) and iii)
c) i) and iii)

“AtoZ Telugu News –Mobile App”


d) i) ii) and iii)
View Answer
Answer: c
Explanation: In i) self loops exist for both the vertices, in iii) self loop exists in the second vertex.
6. Possible number of labelled simple Directed, Pseudo and Multigarphs exist having 2 vertices?
a) 3, Infinite, 4
b) 4, 3, Infinite
c) 4, Infinite, infinite
d) 4, Infinite, Infinite
View Answer
Answer: d
Explanation: MultiGraphs and PseudoGraphs may have infinite number of edges, while 4
possible simple graphs exist.
7. Which of the following is a HyperGraph, where V is the set of vertices, E is the set of edges?
a) V = {v1, v2, v3} E = {e1, e2} = {{v2, v3} {v1, v3}}
b) V = {v1, v2} E = {e1} = {{v1, v2}}
c) V = {v1, v2, v3} E = {e1, e2, e3} = {{v2, v3}{v3, v1}{v2, v1}}
d) All of the mentioned
View Answer
Answer: d
Explanation: In a uniform Graph all the hyper-edges have the same cardinality.
8. What would be the Incidence Matrix of the given HyperGraph?
V = {x,y,z} E = {{x,y}{y}{x,z}{z,y}}
a) {{1,0,1,0},
{1,1,0,1},
{0,0,1,1}}
b) {{1,1,0,0},
{0,1,0,0},
{1,1,1,0}}
c) {{0,1,0,1},
{0,0,1,0},
{1,1,0,0}}
d) None of the Mentioned
View Answer
Answer: a
Explanation: The columns represent edges while rows represent vertices.
9. What is the degree sequence of the given HyperGraph, in non-increasing order.
V = {v1,v2,v3,v4,v5,v6} E = {{v1,v4,v5} {v2,v3,v4,v5} {v2} {v1} {v1,v6}}
a) 3,2,1,1,1,1
b) 3,2,2,2,1,1
c) 3,2,2,2,2,1
d) 3,2,2,1,1,1
View Answer
Answer: b
Explanation: The degree of v1,v2,v3,v4,v5,v6 is 3,2,1,2,2,1 respectively.
10. MultiGraphs having self-loops are called PseudoGraphs?
a) True
b) False
View Answer
Answer: a
Explanation: All PsuedoGraphs are MultiGraphs, but all MultiGraphs are not PseudoGraphs as
all PseudoGraphs have self loop, but all MultiGraphs do not have self loops.

Data Structure Questions and Answers – Linear Search Iterative

“AtoZ Telugu News –Mobile App”


1. Where is linear searching used?
a) When the list has only a few elements
b) When performing a single search in an unordered list
c) Used all the time
d) When the list has only a few elements and When performing a single search in an unordered
list
View Answer
Answer: d
Explanation: It is practical to implement linear search in the situations mentioned in When the
list has only a few elements and When performing a single search in an unordered list, but for
larger elements the complexity becomes larger and it makes sense to sort the list and employ
binary search or hashing.
3. What is the best case for linear search?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
View Answer
Answer: d
Explanation: The element is at the head of the array, hence O(1).
4. What is the worst case for linear search?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
View Answer
Answer: c
Explanation: Worst case is when the desired element is at the tail of the array or not present at
all, in this case you have to traverse till the end of the array, hence the complexity is O(n).
6. What is the best case and worst case complexity of ordered linear search?
a) O(nlogn), O(logn)
b) O(logn), O(nlogn)
c) O(n), O(1)
d) O(1), O(n)
View Answer
Answer: d
Explanation: Although ordered linear search is better than unordered when the element is not
present in the array, the best and worst cases still remain the same, with the key element being
found at first position or at last position.
10. Which of the following is a disadvantage of linear search?
a) Requires more space
b) Greater time complexities compared to other searching algorithms
c) Not easy to understand
d) All of the mentioned
View Answer
Answer: b
Explanation: The complexity of linear search as the name suggests is O(n) which is much
greater than other searching techniques like binary search(O(logn)).

Linear Search Recursive Multiple Choice Questions and Answers (MCQs)

1. Is there any difference in the speed of execution between linear serach(recursive) vs linear
search(lterative)?

“AtoZ Telugu News –Mobile App”


a) Both execute at same speed
b) Linear search(recursive) is faster
c) Linear search(Iterative) is faster
d) Cant be said
View Answer
Answer: c
Explanation: The Iterative algorithm is faster than the latter as recursive algorithm has
overheads like calling function and registering stacks repeatedly.
2. Is the space consumed by the linear search(recursive) and linear search(iterative) same?
a) No, recursive algorithm consumes more space
b) No, recursive algorithm consumes less space
c) Yes
d) Nothing can be said
View Answer
Answer: a
Explanation: The recursive algorithm consumes more space as it involves the usage the stack
space(calls the function numerous times).
3. What is the worst case runtime of linear search(recursive) algorithm?
a) O(n)
b) O(logn)
c) O(n2)
d) O(nx)
View Answer
Answer: a
Explanation: In the worst case scenario, there might be a need of calling the stack n times.
Therfore O(n).
4. Linear search(recursive) algorithm used in _____________
a) When the size of the dataset is low
b) When the size of the dataset is large
c) When the dataset is unordered
d) Never used
View Answer
Answer: a
Explanation: It is used when the size of the dataset is low as its runtime is O(n) which is more
when compared to the binary search O(logn).
5. The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear
search(recursive) algorithm)
a) 4th call
b) 3rd call
c) 6th call
d) 5th call
View Answer
Answer: a
Explanation: Provided that the search starts from the first element, the function calls itself till the
element is found. In this case, the element is found in 4th call.
6. The array is as follows: 1,2,3,6,8,10. Given that the number 17 is to be searched. At which call it
tells that there’s no such element? (By using linear search(recursive) algorithm)
a) 7th call
b) 9th call
c) 17th call
d) The function calls itself infinite number of times
View Answer

“AtoZ Telugu News –Mobile App”


Answer: a
Explanation: The function calls itself till the element is found. But at the 7th call it terminates as
goes outside the array.
7. What is the best case runtime of linear search(recursive) algorithm on an ordered set of
elements?
a) O(1)
b) O(n)
c) O(logn)
d) O(nx)
View Answer
Answer: a
Explanation: The best case occurs when the given element to be found is at the first position.
Therefore O(1) is the correct answer

Data Structure Questions and Answers – Binary Search Iterative

1. What is the advantage of recursive approach than an iterative approach?


a) Consumes less memory
b) Less code and easy to implement
c) Consumes more memory
d) All of the mentioned
View Answer
Answer: b
Explanation: A recursive approach is easier to understand and contains fewer lines of code.
3. Given an input arr = {2,5,7,99,899}; key = 899; What is the level of recursion?
a) 5
b) 2
c) 3
d) 4
View Answer
Answer: c
Explanation: level 1: mid = 7
level 2: mid = 99
level 3: mid = 899(this is the key).
4. Given an array arr = {45,77,89,90,94,99,100} and key = 99; what are the mid
values(corresponding array elements) in the first and second levels of recursion?
a) 90 and 99
b) 90 and 94
c) 89 and 99
d) 89 and 94
View Answer
Answer: a
Explanation: Trace the input with the binary search recursive code.
5. What is the worst case complexity of binary search using recursion?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: b
Explanation: Using the divide and conquer master theorem.
6. What is the average case time complexity of binary search using recursion?
a) O(nlogn)

“AtoZ Telugu News –Mobile App”


b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: b
Explanation: T(n) = T(n/2) + 1, Using the divide and conquer master theorem.
7. What are the applications of binary search?
a) To find the lower/upper bound in an ordered sequence
b) Union of intervals
c) Debugging
d) All of the mentioned
View Answer
Answer: d
Explanation: All of the mentioned can be realized by binary search.
9. Binary Search can be categorized into which of the following?
a) Brute Force technique
b) Divide and conquer
c) Greedy algorithm
d) Dynamic programming
View Answer
Answer: b
Explanation: Since ‘mid’ is calculated for every iteration or recursion, we are diving the array into
half and then try to solve the problem.
10. Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until the
element is found?
a) 1
b) 3
c) 4
d) 2
View Answer
Answer: d
Explanation: Iteration1 : mid = 77; Iteration2 : mid = 88;
11. Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid
values(corresponding array elements) generated in the first and second iterations?
a) 90 and 99
b) 90 and 100
c) 89 and 94
d) 94 and 99
View Answer
Answer: a
Explanation: Trace the input with the binary search iterative code.
12. What is the time complexity of binary search with iteration?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: b
Explanation: T(n) = T(n/2) + theta(1)
Using the divide and conquer master theorem, we get the time complexity as O(logn)

Data Structure Questions and Answers – Uniform Binary Search

“AtoZ Telugu News –Mobile App”


1. When is the uniform binary search an optimization over the usual binary search?
a) A table lookup is generally faster than an addition and a shift
b) Many searches will be performed on the same array
c) Many searches will be performed on several arrays of the same length
d) All of the mentioned
View Answer
Answer: d
Explanation: Suitable for architectures such as Knuth’s MIX and MMIX and this algorithm was
proposed by Donald Knuth.
3. Given delta[4] is a global array and number of elements in the sorted array is 10, what are the
values in the delta array?
a) 4, 3, 1, 0
b) 5, 3, 1, 0
c) 4, 2, 1, 1
d) 5, 2, 1, 1
View Answer
Answer: b
Explanation: Trace with respect to the make_delta function, always note that the last element is
always 0.
5. What is the time complexity of uniform binary search?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: b
Explanation: With every iteration we are dividing the array into two parts(though not equal
halves), the complexity remains same as the normal binary search.
6. Given, arr = {1,3,5,6,7,9,14,15,17,19} key = 17 and delta = {5,3,1,0}
How many key comparisons are made?(exclude the comparison used to decide the left or right
sub array)
a) 4
b) 3
c) 5
d) 6
View Answer
Answer: b
Explanation: Tracing with the above code, comparison #1: i=4, comparison #2: i=7, comparison
#3: i=8
7. How can Jump Search be improved?
a) Start searching from the end
b) Begin from the kth item, where k is the step size
c) Cannot be improved
d) Step size should be other than sqrt(n)
View Answer
Answer: b
Explanation: This gives a very slight improvement as you are skipping the first k elements.
8. Which of the following false about Jump Search?
a) Jump Search is better than Linear Search
b) Useful when jumping back is more costly than jumping forward
c) Jump Search is worse than Binary Search
d) None of the mentioned
View Answer

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: All of the statements are true, Linear search has O(n) complexity and Binary
search has O(logn) complexity, in Jump search you have to jump backwards only once, hence it
is preferable if jumping backwards is costly.

Insertion Sort Multiple Choice Questions and Answers (MCQs) – 1

1. How many passes does an insertion sort algorithm consist of?


a) N
b) N-1
c) N+1
d) N2
View Answer
Answer: b
Explanation: An insertion algorithm consists of N-1 passes when an array of N elements is
given.
2. Which of the following algorithm implementations is similar to that of an insertion sort?
a) Binary heap
b) Quick sort
c) Merge sort
d) Radix sort
View Answer
Answer: a
Explanation: Insertion sort is similar to that of a binary heap algorithm because of the use of
temporary variable to swap.
3. What is the average case running time of an insertion sort algorithm?
a) O(N)
b) O(N log N)
c) O(log N)
d) O(N2)
View Answer
Answer: d
Explanation: The average case analysis of a tight bound algorithm is mathematically achieved
to be O(N2).
4. Any algorithm that sorts by exchanging adjacent elements require O(N 2) on average.
a) True
b) False
View Answer
Answer: a
Explanation: Each swap removes only one inversion, so O(N 2) swaps are required.
5. What is the average number of inversions in an array of N distinct numbers?
a) N(N-1)/4
b) N(N+1)/2
c) N(N-1)/2
d) N(N-1)/3
View Answer
Answer: a
Explanation: The total number of pairs in a list L is N(N-1)/2. Thus, an average list has half this
amount, or N(N-1)/4 inversions.
6. What is the running time of an insertion sort algorithm if the input is pre-sorted?
a) O(N2)
b) O(N log N)
c) O(N)

“AtoZ Telugu News –Mobile App”


d) O(M log N)
View Answer
Answer: c
Explanation: If the input is pre-sorted, the running time is O(N), because the test in the inner for
loop always fails immediately and the algorithm will run quickly.
7. What will be the number of passes to sort the elements using insertion sort?
14, 12,16, 6, 3, 10
a) 6
b) 5
c) 7
d) 1
View Answer
Answer: b
Explanation: The number of passes is given by N-1. Here, N=6. Therefore,
6-1=5 passes.
8. For the following question, how will the array elements look like after second pass?
34, 8, 64, 51, 32, 21
a) 8, 21, 32, 34, 51, 64
b) 8, 32, 34, 51, 64, 21
c) 8, 34, 51, 64, 32, 21
d) 8, 34, 64, 51, 32, 21
View Answer
Answer: d
Explanation: After swapping elements in the second pass, the array will look like, 8, 34, 64, 51,
32, 21.
9. Which of the following real time examples is based on insertion sort?
a) arranging a pack of playing cards
b) database scenarios and distributes scenarios
c) arranging books on a library shelf
d) real-time systems
View Answer
Answer: a
Explanation: Arranging a pack of cards mimics an insertion sort. Database scenario is an
example for merge sort, arranging books is a stack and real-time systems uses quick sort.
10. In C, what are the basic loops required to perform an insertion sort?
a) do- while
b) if else
c) for and while
d) for and if
View Answer
Answer: c
Explanation: To perform an insertion sort, we use two basic loops- an outer for loop and an
inner while loop.
11. Binary search can be used in an insertion sort algorithm to reduce the number of comparisons.
a) True
b) False
View Answer
Answer: a
Explanation: Binary search can be used in an insertion sort algorithm to reduce the number of
comparisons. This is called a Binary insertion sort.
12. Which of the following options contain the correct feature of an insertion sort algorithm?
a) anti-adaptive
b) dependable
c) stable, not in-place

“AtoZ Telugu News –Mobile App”


d) stable, adaptive
View Answer
Answer: d
Explanation: An insertion sort is stable, adaptive, in-place and incremental in nature

Insertion Sort Multiple Choice Questions and Answers (MCQs) – 2


1. Which of the following is correct with regard to insertion sort?
a) insertion sort is stable and it sorts In-place
b) insertion sort is unstable and it sorts In-place
c) insertion sort is stable and it does not sort In-place
d) insertion sort is unstable and it does not sort In-place
View Answer
Answer: a
Explanation: During insertion sort, the relative order of elements is not changed. Therefore, it is
a stable sorting algorithm. And insertion sort requires only O(1) of additional memory space.
Therefore, it sorts In-place.
2. Which of the following sorting algorithm is best suited if the elements are already sorted?
a) Heap Sort
b) Quick Sort
c) Insertion Sort
d) Merge Sort
View Answer
Answer: c
Explanation: The best case running time of the insertion sort is O(n). The best case occurs
when the input array is already sorted. As the elements are already sorted, only one comparison
is made on each pass, so that the time required is O(n).
3. The worst case time complexity of insertion sort is O(n2). What will be the worst case time
complexity of insertion sort if the correct position for inserting element is calculated using binary
search?
a) O(nlogn)
b) O(n2)
c) O(n)
d) O(logn)
View Answer
Answer: b
Explanation: The use of binary search reduces the time of finding the correct position from O(n)
to O(logn). But the worst case of insertion sort remains O(n2) because of the series of swapping
operations required for each insertion.
4. Insertion sort is an example of an incremental algorithm.
a) True
b) False
View Answer
Answer: a
Explanation: In the incremental algorithms, the complicated structure on n items is built by first
building it on n − 1 items. And then we make the necessary changes to fix things in adding the
last item. Insertion sort builds the sorted sequence one element at a time. Therefore, it is an
example of an incremental algorithm.
6. Which of the following is good for sorting arrays having less than 100 elements?
a) Quick Sort
b) Selection Sort
c) Merge Sort
d) Insertion Sort
View Answer

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: The insertion sort is good for sorting small arrays. It sorts smaller arrays faster than
any other sorting algorithm.
7. Consider an array of length 5, arr[5] = {9,7,4,2,1}. What are the steps of insertions done while
running insertion sort on the array?
a) 7 9 4 2 1 4 7 9 2 1 2 4 7 9 1 1 2 4 7 9
b) 9 7 4 1 2 9 7 1 2 4 9 1 2 4 7 1 2 4 7 9
c) 7 4 2 1 9 4 2 1 9 7 2 1 9 7 4 1 9 7 4 2
d) 7 9 4 2 1 2 4 7 9 1 4 7 9 2 1 1 2 4 7 9
View Answer
Answer: a
Explanation: The steps performed while running insertion sort on given array are:
Initial : -9 7 4 2 1
79421
47921
24791
12479
In each step, the element under consideration is underlined and the element which is placed into
its correct position in the previous step is shown in bold.
6. Which of the following is good for sorting arrays having less than 100 elements?
a) Quick Sort
b) Selection Sort
c) Merge Sort
d) Insertion Sort
View Answer
Answer: d
Explanation: The insertion sort is good for sorting small arrays. It sorts smaller arrays faster than
any other sorting algorithm.
7. Consider an array of length 5, arr[5] = {9,7,4,2,1}. What are the steps of insertions done while
running insertion sort on the array?
a) 7 9 4 2 1 4 7 9 2 1 2 4 7 9 1 1 2 4 7 9
b) 9 7 4 1 2 9 7 1 2 4 9 1 2 4 7 1 2 4 7 9
c) 7 4 2 1 9 4 2 1 9 7 2 1 9 7 4 1 9 7 4 2
d) 7 9 4 2 1 2 4 7 9 1 4 7 9 2 1 1 2 4 7 9
View Answer
Answer: a
Explanation: The steps performed while running insertion sort on given array are:
Initial : -9 7 4 2 1
79421
47921
24791
12479
In each step, the element under consideration is underlined and the element which is placed into
its correct position in the previous step is shown in bold.

8. Statement 1: In insertion sort, after m passes through the array, the first m elements are in
sorted order.
Statement 2: And these elements are the m smallest elements in the array.
a) Both the statements are true
b) Statement 1 is true but statement 2 is false
c) Statement 1 is false but statement 2 is true
d) Both the statements are false
View Answer

“AtoZ Telugu News –Mobile App”


Answer: b
Explanation: In insertion sort, after m passes through the array, the first m elements are in
sorted order but they are whatever the first m elements were in the unsorted array.
9. In insertion sort, the average number of comparisons required to place the 7 th element into its
correct position is ____
a) 9
b) 4
c) 7
d) 14
View Answer
Answer: b
Explanation: On average (k + 1) / 2 comparisons are required to place the kth element into its
correct position. Therefore, average number of comparisons required for 7th element = (7 + 1)/2
= 4.
10. Which of the following is not an exchange sort?
a) Bubble Sort
b) Quick Sort
c) Partition-exchange Sort
d) Insertion Sort
View Answer
Answer: d
Explanation: In Exchange sorts, we compare each element of an array and swap those
elements that are not in their proper position. Bubble Sort and Quick Sort are exchange sorts.
Quick Sort is also called as Partition-exchange Sort. Insertion sort is not an exchange sort.

Data Structure Questions and Answers – Selection Sort

1. What is an in-place sorting algorithm?


a) It needs O(1) or O(logn) memory to create auxiliary locations
b) The input is already sorted and in-place
c) It requires additional storage
d) None of the mentioned
View Answer
Answer: a
Explanation: Auxiliary memory is required for storing the data temporarily.
2. In the following scenarios, when will you use selection sort?
a) The input is already sorted
b) A large file has to be sorted
c) Large values need to be sorted with small keys
d) Small values need to be sorted with large keys
View Answer
Answer: c
Explanation: Selection is based on keys, hence a file with large values and small keys can be
efficiently sorted with selection sort.
3. What is the worst case complexity of selection sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: d
Explanation: Selection sort creates a sub-list, LHS of the ‘min’ element is already sorted and
RHS is yet to be sorted. Starting with the first element the ‘min’ element moves towards the final
element.

“AtoZ Telugu News –Mobile App”


5. What is the advantage of selection sort over other sorting techniques?
a) It requires no additional storage space
b) It is scalable
c) It works best for inputs which are already sorted
d) It is faster than any other sorting technique
View Answer
Answer: a
Explanation: Since selection sort is an in-place sorting algorithm, it does not require additional
storage.
advertisement
6. What is the average case complexity of selection sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: d
Explanation: In the average case, even if the input is partially sorted, selection sort behaves as
if the entire array is not sorted. Selection sort is insensitive to input.
7. What is the disadvantage of selection sort?
a) It requires auxiliary memory
b) It is not scalable
c) It can be used for small keys
d) None of the mentioned
View Answer
Answer: b
Explanation: As the input size increases, the performance of selection sort decreases.
8. The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort
respectively are,
a) 5 and 4
b) 4 and 5
c) 2 and 4
d) 2 and 5

Answer: a
Explanation: Since the input array is not sorted, bubble sort takes 5 iterations and selection sort
takes 4(n-1) iterations.
9. The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number
of iterations in selection sort and bubble sort respectively are,
a) 5 and 4
b) 1 and 4
c) 0 and 4
d) 4 and 1

Answer: b
Explanation: Selection sort is insensitive to input, hence 4(n-1) iterations. Whereas bubble sort
iterates only once to set the flag to 0 as the input is already sorted.
10. What is the best case complexity of selection sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

“AtoZ Telugu News –Mobile App”


Answer: d
Explanation: The best, average and worst case complexities of selection sort is O(n 2).
(n-1) + (n-2) + (n-3) + …. + 1 = (n(n-1))/2 ~ (n2)/2.

– Bubble Sort

1. What is an external sorting algorithm?


a) Algorithm that uses tape or disk during the sort
b) Algorithm that uses main memory during the sort
c) Algorithm that involves swapping
d) Algorithm that are considered ‘in place’

Answer: a
Explanation: As the name suggests, external sorting algorithm uses external memory like tape
or disk.
2. What is an internal sorting algorithm?
a) Algorithm that uses tape or disk during the sort
b) Algorithm that uses main memory during the sort
c) Algorithm that involves swapping
d) Algorithm that are considered ‘in place’

Answer: b
Explanation: As the name suggests, internal sorting algorithm uses internal main memory.
3. What is the worst case complexity of bubble sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

Answer: d
Explanation: Bubble sort works by starting from the first element and swapping the elements if
required in each iteration.
5. What is the average case complexity of bubble sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

Answer: d
Explanation: Bubble sort works by starting from the first element and swapping the elements if
required in each iteration even in the average case.
6. What is the advantage of bubble sort over other sorting techniques?
a) It is faster
b) Consumes less memory
c) Detects whether the input is already sorted
d) All of the mentioned

Answer: c
Explanation: Bubble sort is one of the simplest sorting techniques and perhaps the only
advantage it has over other techniques is that it can detect whether the input is already sorted.
7. The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many
iterations will be done to sort the array?
a) 4
b) 2

“AtoZ Telugu News –Mobile App”


c) 1
d) 0

Answer: a
Explanation: Even though the first two elements are already sorted, bubble sort needs 4
iterations to sort the given array.
9. What is the best case efficiency of bubble sort in the improvised version?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

Answer: c
Explanation: Some iterations can be skipped if the list is sorted, hence efficiency improves to
O(n).
10. The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many
iterations will be done to sort the array with improvised version?
a) 4
b) 2
c) 1
d) 0

Answer: b
Explanation: Only 2 elements in the given array are not sorted, hence only 2 iterations are
required to sort them.

IMPORTANT BITS ----- DATA STRUCTURES:

1. Stack is also called as

a. First in first out

b. First in last out

c. Last in last out

d. Last in first out

ANSWER: D

2. Any node is the path from the root to the node is called

a. Ancestor node

b. Successor node

c. Internal node

d. None of the above

“AtoZ Telugu News –Mobile App”


ANSWER: A

3. Which of the following is not the type of queue?

a. Priority queue

b. Circular queue

c. Single ended queue √√

d. Ordinary queue

ANSWER: C

4. A graph is a collection of nodes, called...... And line segments called arcs or

...... that connect pair of nodes.

a. vertices, paths

b. vertices, edges √√

c. graph node, edges

d. edges, vertices

ANSWER: B

5. In ........, search start at the beginning of the list and check every element in

the list.

a. Binary search

b. Hash Search

c. Linear search √√

d. Binary Tree search

ANSWER: C

6. In the ....... traversal we process all of a vertex’s descendants before we

move to an adjacent vertex.

“AtoZ Telugu News –Mobile App”


a. Depth Limited

b. With First

c. Breadth First

d. Depth First

ANSWER; D

7. To represent hierarchical relationship between elements, which data

structure is suitable?

a. Graph

b. Tree

c. Dequeue

d. Priority

ANSWER: B

8. Which of the following data structure is linear type?

a. Stack

b. Graph

c. Trees

d. Binary tree

ANSWER; A

9. Herder node is used as sentinel in........

a. Queues

b. Stacks

c. Graphs

d. Binary tree

ANSWER: D

“AtoZ Telugu News –Mobile App”


10.Which of the following data structure can’t store the nonhomogeneous

data elements?

a. Arrays √√

b. Stacks

c. Records

d. None of the above

ANSWER: A

(11) A binary search tree whose left subtree and right subtree differ in hight by at most 1 unit is called
.....

[A] Lemma tree

[B] Redblack tree

[C] AVL tree

[D] None of the above

Answer: Option [C]

(12) ....... is a pile in which items are added at one end and removed from the other.

[A] List

[B] Queue

[C] Stack

[D] Array

Answer: Option [B]

(13) Which of the following is non-linear data structure?

[A] Trees

[B] Stacks

[C] Strings

[D] All of the above


“AtoZ Telugu News –Mobile App”
Answer: Option [A]

(14) The number of comparisons done by sequential search is .......

[A] (N/2)+1

[B] (N+1)/2

[C] (N-1)/2

[D] (N-2)/2

Answer: Option [B]

(15) ...... is not the operation that can be performed on queue.

[A] Traversal

[B] Insertion

[C] Deletion

[D] Retrieval

Answer: Option [A]

(16) Which is/are the application(s) of stack

[A] Function calls

[B] Large number Arithmetic

[C] Evaluation of arithmetic expressions

[D] All of the above

Answer: Option [D]

(17) Which of the following data structures are indexed structures?

[A] Stack

[B] Linked lists

[C] Linear arrays

“AtoZ Telugu News –Mobile App”


[D] None of the above

Answer: Option [C]

(18) Which of the following data structure store the homogeneous data elements?

[A] Lists

[B] Pointers

[C] Records

[D] Arrays

Answer: Option [C]

(19) Linear arrays are also called.......

[A] One-dimensional array

[B] Vertical array

[C] Horizontal array

[D] All of the above

Answer: Option [A]

(20) A ......... does not keep track of address of every element in the list.

[A] Stack

[B] Queue

[C] String

[D] Linear array

Answer: Option [D]

(21) The complexity of linear search algorithm is

[A] O(n)

[B] O(log n)

“AtoZ Telugu News –Mobile App”


[C] O(n2)

[D] O(n log n)

Answer: Option [A]

(22) The complexity of Binary search algorithm is

[A] O(n)

[B] O(log n)

[C] O(n2)

[D] O(n log n)

Answer: Option [B]

(23) The complexity of Bubble sort algorithm is

[A] O(n)

[B] O(log n)

[C] O(n2)

[D] O(n log n)

Answer: Option [C]

(24) The complexity of merge sort algorithm is

[A] O(n)

[B] O(log n)

[C] O(n2)

[D] O(n log n)

Answer: Option [D]

(25) The space factor when determining the efficiency of algorithm is measured by

[A] Counting the maximum memory needed by the algorithm

“AtoZ Telugu News –Mobile App”


[B] Counting the minimum memory needed by the algorithm

[C] Counting the average memory needed by the algorithm

[D] Counting the maximum disk space needed by the algorithm

Answer: Option [A]

(26) The operation of processing each element in the list is known as

[A] Traversal

[B] Inserting

[C] Merging

[D] Sorting

Answer: Option [A]

(27) Binary trees with threads are called as.......

[A] Special trees

[B] Pointer trees

[C] Threaded trees

[D] None of the above

Answer: Option [C]

(28) In Binary trees nodes with no successor are called......

[A] End nodes

[B] Final nodes

[C] Last nodes

[D] Terminal nodes

Answer: Option [D]

(29) The depth of a complete binary tree is given by

“AtoZ Telugu News –Mobile App”


[A] Dn = n log2n

[B] Dn = n log2n+1

[C] Dn = log2n

[D] Dn = log2n+1

Answer: Option [D]

(30) Every node N in a binary tree T except the root has a unique parent called the ......... of N.

[A] Predecessor

[B] Antecedents

[C] Precursor

[D] None of the above

Answer: Option [A]

(31) The in order traversal of tree will yield a sorted listing of elements of tree in....

[A] Merging

[B] AVL Trees

[C] Binary trees

[D] Binary search trees

Answer: Option [D]

(32) A binary tree whose every node has either zero or two children is called.........

[A] Extended binary tree

[B] Complete binary tree

[C] Binary Search tree

[D] Disjoint tree

Answer: Option [A]

“AtoZ Telugu News –Mobile App”


(33) The post order traversal of a binary tree is DEBFCA. Find out the pre order traversal

[A] ABFCDE

[B] ADBFEC

[C] ABDECF

[D] ABDCEF

Answer: Option [C]

(34) Three standards ways of traversing a binary tree T with root R .......

[A] Prefix, infix, postfix

[B] Pre-process, in-process, post-process

[C] Pre-traversal, in-traversal, post-traversal

[D] Pre-order, in-order, post-order

Answer: Option [D]

(35) A technique for direct search is

[A] Hashing

[B] Tree Search

[C] Binary Search

[D] Linear Search

Answer: Option [A]

(36) If a node having two children is deleted from a binary tree, it is replaced by its

[A] Preorder predecessor

[B] Inorder predecessor

[C] Inorder successor

[D] Preorder successor

Answer: Option [C]

“AtoZ Telugu News –Mobile App”


(37) A full binary tree with 2n+1 nodes contain

[A] n leaf nodes

[B] n non-leaf nodes

[C] n-1 leaf nodes

[D] n-1 non-leaf nodes

Answer: Option [B]

(38) A full binary tree with n leaves contains

[A] n - 1 nodes

[B] log2n nodes

[C] 2n – 1 nodes

[D] 2n nodes

Answer: Option [C]

(39) The smallest element of an array’s index is called its

[A] extraction

[B] range

[C] lower bound

[D] upper bound

Answer: Option [C]

(40) The data structure required for Breadth First Traversal on a graph is

[A] queue

[B] stack

[C] array

[D] None of the above

“AtoZ Telugu News –Mobile App”


Answer: Option [A]

(41) One can convert a binary tree into its mirror image by traversing it in

[A] inorder

[B] preorder

[C] postorder

[D] None of the above

Answer: Option [C]

(42) The data structure required to evaluate a postfix expression is

[A] queue

[B] stack

[C] linked-list

[D] All of the above

Answer: Option [B]

(43) Which of the following sorting methods would be most suitable for sorting a list which is almost
sorted

[A] Insertion Sort

[B] Selection Sort

[C] Quick Sort

[D] Bubble Sort

Answer: Option [D]

(44) The process of accessing data stored in a serial access memory is similar to manipulating data on a

[A] heap

[B] queue

[C] stack
“AtoZ Telugu News –Mobile App”
[D] None of the above

Answer: Option [C]

(45) The postfix form of A*B+C/D is

[A] ABCD+/*

[B] AB*CD/+

[C] *AB/CD+

[D] A*BC+/D

Answer: Option [B]

(46) A linear collection of data elements where the linear node is given by means of pointer is called

[A] linked list

[B] node list

[C] primitive list

[D] None of these

Answer: Option [A]

(47) Representation of data structure in memory is known as:

[A] storage structure

[B] file structure

[C] abstract data type

[D] None of the above

Answer: Option [C]

(48) The goal of hashing is to produce a search that takes

[A] O(1) time

[B] O(n2) time

“AtoZ Telugu News –Mobile App”


[C] O(log n) time

[D] O(n log n) time

Answer: Option [A]

(49) The complexity of multiplying two matrices of order m*n and n*p is

[A] np

[B] mn+p

[C] mn

[D] mnp

Answer: Option [D]

(50) For an undirected graph with n vertices and e edges, the sum of the degree of each vertex is equal
to

[A] 2n

[B] 2e

[C] (e2+1)/2

[D] (2n-1)/2

Answer: Option [B]

(51) Which data structure allows deleting data elements from and inserting at rear?

[A] Stacks

[B] Queues

[C] Dequeues

[D] Binary search tree

Answer: Option [B]

(52) Which data structure is used in breadth first search of a graph to hold nodes?

[A] Array
“AtoZ Telugu News –Mobile App”
[B] Tree

[C] Stack

[D] queue

Answer: Option [D]

(53) Identify the data structure which allows deletions at both ends of the list but insertion at only one
end.

[A] Stack

[B] Priority queues

[C] Output restricted qequeue

[D] Input restricted dequeue

Answer: Option [D]

(54) Which of the following data structure is non linear type?

[A] Graph

[B] Stacks

[C] Lists

[D] None of the above

Answer: Option [A]

(55) In a queue, the initial values of front pointer f rare pointer r should be …….. and ……….. respectively.

[A] 0 and 1

[B] 0 and -1

[C] -1 and 0

[D] 1 and 0

Answer: Option [B]

(56) There is an extra element at the head of the list called a .........
“AtoZ Telugu News –Mobile App”
[A] Sentinel

[B] Antinel

[C] List head

[D] List header

Answer: Option [A]

(57) The property of binary tree is

[A] The root cannot contain NULL

[B] The first subset is called left subtree

[C] The second subtree is called right subtree

[D] The right subtree can be empty

Answer: Option [D]

(58) When new data are to be inserted into a data structure, but there is not available space; this
situation is usually called .......

[A] overflow

[B] Underflow

[C] housefull

[D] memoryfull

Answer: Option [A]

(59) A data structure where elements can be added or removed at either end but not in the middle is
called ......

[A] stacks

[B] queues

[C] dequeue

[D] linked lists

Answer: Option [C]

“AtoZ Telugu News –Mobile App”


(60) The use of pointers to refer elements of a data structure in which elements are logically adjacent is
......

[A] stack

[B] queue

[C] pointers

[D] linked allocation

Answer: Option [D]

(61) Binary search algorithm cannot be applied to...

[A] pointer array

[B] sorted linear array

[C] sorted binary trees

[D] sorted linked list

Answer: Option [A]

(62) ............ is the method used by card sorter?

[A] Quick

[B] Heap

[C] Insertion

[D] Radix sort

Answer: Option [D]

(63) Which of the following conditions checks available free space in avail list?

[A] Avail=Top

[B] Null=Avail

[C] Avail=Null

[D] Avail=Max stack


“AtoZ Telugu News –Mobile App”
Answer: Option [C]

(64) Which of the following is not the type of queue?

[A] Priority queue

[B] Circular queue

[C] Ordinary queue

[D] Single ended queue

Answer: Option [D]

(65) ........ is a directed tree in which outdegree of each node is less than or equal to two.

[A] Binary tree

[B] Dinary tree

[C] Unary tree

[D] None of the above

Answer: Option [A]

(66) The number of comparisons done by sequential search is .......

[A] (N/2)-1

[B] (N+1)/2

[C] (N-1)/2

[D] (N+2)/2

Answer: Option [B]

(67) In ......, search start at the beginning of the list and check every element in the list.

[A] Hash Search

[B] Binary search

[C] Linear search

“AtoZ Telugu News –Mobile App”


[D] Binary Tree search

Answer: Option [C]

(68) The operation that combines the element is of A and B in a single sorted list C with n=r+s element is
called.......

[A] Sharing

[B] Merging

[C] Inserting

[D] None of the above

Answer: Option [B]

(69) Which of the following is an internal sorting?

[A] 2-way Merge Sort

[B] Tape Sort

[C] Merge Sort

[D] Tree Sort

Answer: Option [D]

(70) Which of the following is an external sorting?

[A] Merge Sort

[B] Tree Sort

[C] Bubble Sort

[D] Insertion Sort

Answer: Option [A]

(71) ...... is the term used to insert an element into stack?

[A] Push

[B] Pull
“AtoZ Telugu News –Mobile App”
[C] Pop

[D] All of the above

Answer: Option [A]

(72) .......... is the term used to delete an element from the stack?

[A] Push

[B] Pull

[C] Pop

[D] All of the above

Answer: Option [C]

(73) Before inserting into stack one must check the condition.........

[A] Overflow

[B] Underflow

[C] Maximum elements

[D] Existing elements

Answer: Option [A]

(74) Deletion in the linked stack takes place by deleting........

[A] Beginning of the list

[B] End of the list

[C] Middle of the list

[D] Node pointed by the start process.

Answer: Option [D]

(75) The value of REAR is increased by 1 when.......

[A] An element is merged in a queue

“AtoZ Telugu News –Mobile App”


[B] An element is added in a queue

[C] An element is traversed in a queue

[D] An element is deleted in a queue

Answer: Option [B]

(76) The operation of processing each element in the list is known as......

[A] merging

[B] traversal

[C] inserting

[D] sorting

Answer: Option [B]

(77) Sequential representation of binary tree uses........

[A] Array with pointers

[B] Single linear array

[C] Two dimensional arrays

[D] Three dimensional arrays

Answer: Option [A]

(78) In a 2-tree, nodes with 0 children are called............

[A] Outer node

[B] Exterior node

[C] External node

[D] Outside node

Answer: Option [C]

(79) In a extended-binary tree nodes with 2 children are called........

“AtoZ Telugu News –Mobile App”


[A] Inner node

[B] Internal node

[C] Domestic node

[D] Interior node

Answer: Option [B]

(80) The line drawn from a node N of tree T to a successor is called .......

[A] Route

[B] Arrow

[C] Edge

[D] Path

Answer: Option [C]

(81) Which of the following sorting algorithms does not have a worst case running time of O(n2)?

[A] Insertion sort

[B] Quick sort

[C] Bubble sort

[D] Merge sort

Answer: Option [D]

(82) In a circular linked list

[A] there is no beginning and no end.

[B] components are arranged hierarchically.

[C] forward and backward traversal within the list is permitted.

[D] components are all linked together in some sequential manner.

Answer: Option [A]

“AtoZ Telugu News –Mobile App”


(83) The quick sort algorithm exploit _________ design technique

[A] Overflow

[B] Backtracking

[C] Dynamic programming

[D] Divide and Conquer

Answer: Option [D]

(84) The data structure required to check whether an expression contains balanced parenthesis is

[A] Stack

[B] Queue

[C] Tree

[D] Array

Answer: Option [A]

(85) What data structure would you mostly likely see in a nonrecursive implementation of a recursive
algorithm?

[A] Trees

[B] Linked list

[C] Stack

[D] Queue

Answer: Option [C]

(86) The number of leaf nodes in a complete binary tree of depth d is

[A] 2d

[B] 2d–1+1

[C] 2d+1+1

[D] 2d+1

Answer: Option [A]


“AtoZ Telugu News –Mobile App”
(87) The pre-order and post order traversal of a Binary Tree generates the same output. The tree can
have maximum

[A] One node

[B] Two nodes

[C] Three nodes

[D] Any number of nodes

Answer: Option [A]

(88) A binary tree of depth “d” is an almost complete binary tree if

[A] Each leaf in the tree is either at level “d” or at level “d–1”

[B] For any node “n” in the tree with a right descendent at level “d” all the left descendents of “n” that
are leaves, are also at level “d”

[C] Both (A) & (B)

[D] None of the above

Answer: Option [C]

(89) In a binary tree a sequence of consecutive edges is called ......

[A] Path

[B] Rotate

[C] Two-way

[D] Connecting lines

Answer: Option [A]

(90) An adjacency matrix representation of a graph cannot contain information of:

[A] nodes

[B] edges

[C] parallel edges

“AtoZ Telugu News –Mobile App”


[D] direction of edges

Answer: Option [C]

(91) ........ is not the operation that can be performed on queue.

[A] Traversal

[B] Retrieval

[C] Deletion

[D] Insertion

Answer: Option [A]

(92) A linear list in which the last node points to the first node is ........

[A] singly linked list

[B] doubly linked list

[C] circular linked list

[D] none of the above

Answer: Option [C]

(93) A linear list in which the pointer points only to the successive node is......

[A] singly linked list

[B] circular linked list

[C] doubly linked list

[D] none of the above

Answer: Option [A]

(94) A ...... indicates the end of the list.

[A] Guard

[B] Sentinel

“AtoZ Telugu News –Mobile App”


[C] End pointer

[D] Last pointer

Answer: Option [B]

(95) LLINK is the pointer pointing to the ......

[A] head node

[B] last node

[C] successor node

[D] predecessor node

Answer: Option [D]

(96) Indexing the........ element in the list is not possible in linked lists.

[A] first

[B] middle

[C] last

[D] All of the above

Answer: Option [B]

(97) A doubly linked list has .......... pointers with each node.

[A] 0

[B] 1

[C] 2

[D] 3

Answer: Option [C]

(98) A linear list in which each node has point to the predecessor and successors nodes is called ........

[A] singly linked list

“AtoZ Telugu News –Mobile App”


[B] linear linked list

[C] doubly linked list

[D] None of the above

Answer: Option [C]

(99) RLINK is the pointer pointing to the......

[A] last node

[B] head node

[C] successor node

[D] predecessor node

Answer: Option [C]

(100) In a linked list, insertion can be done as.........

[A] beginning

[B] middle

[C] end

[D] all of the above

Answer: Option [D]

PRACTICE BITS- 1:

1. …………………. Is a directed tree in which outdegree of each node is less than or equal to two

A ) Unary tree

B ) Ternary tree

C ) Binary tree

D ) Both B and C

Answer : C

2. Which if the following is/are the levels of implementation of data structure

“AtoZ Telugu News –Mobile App”


A ) Abstract level

B ) Application level

C ) Implementation level

D ) All of the above

Answer : D

3. Which is/are the application(s) of stack

A ) Function calls

B ) Large number Arithmetic

C ) Evaluation of arithmetic expressions D ) All of the above

Answer : D

4. Quick sort is also known as

A ) merge sort

B ) heap sort

C ) bubble sort

D ) none of these

Answer : D

5. If the address of A[1][1] and A[2][1] are 1000 and 1010 respectively and each element occupies 2
bytes then the array has been stored in _________ order

A) row major

B ) column major

C ) matrix major

D ) none of above

Answer : A

6. A binary search tree whose left subtree and right subtree differ in height by at most 1 unit is called
“AtoZ Telugu News –Mobile App”
A ) AVL tree

B ) Red-black tree

C ) Lemma tree

D ) None of the above

Answer : A

7. …………… is not the component of data structure.

A ) Operations

B ) Storage Structures

C ) Algorithms

D ) None of above

Answer : D

8. An adjacency matrix representation of a graph cannot contain information of

A ) nodes

B ) edges

C ) direction of edges

D ) parallel edges

Answer : D

9. ………………. is not an operation performed on linear list

A ) Insertion

B ) Insertion & Deletion

C ) Deletion & Traversal

D ) None of the above

Answer : D

“AtoZ Telugu News –Mobile App”


10. Any node is the path from the root to the node is called

A ) Successor node

B ) Ancestor node

C ) Internal node

D ) None of the above

Answer : B

11. Stack is also called as

A ) Last in first out

B ) First in last out

C) Last in last out

D ) First in first out

Answer : A

12. The property of binary tree is

A ) The first subset is called left subtree B ) The second subtree is called right subtree

C ) The root cannot contain NULL

D ) The right subtree can be empty

Answer : D

13. ……………. Is a pile in which items are added at one end and removed from the other.

A ) Stack

B ) Queue

C ) List

D ) None of the above

Answer : B

“AtoZ Telugu News –Mobile App”


14. Inserting an item into the stack when stack is not full is called …………. Operation and deletion of item
form the stack, when stack is not empty is called ………..operation.

A ) push, pop

B ) pop, push

C ) insert , delete

D ) delete , insert

Answer : A

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

A ) Abstract level

B ) Application level

C ) Implementation level

D ) All of the above

Answer : C

16. Which of the following is not the type of queue?

A ) Ordinary queue

B ) Single ended queue

C ) Circular queue

D ) Priority queue

Answer : B

17. Which of the following is not the part of ADT description?

A ) Data

B ) Operations

C ) Both of the above


“AtoZ Telugu News –Mobile App”
D ) None of the above

Answer : D

18. ………… is very useful in situation when data have to stored and then retrieved in reverse order.

A ) Stack

B ) Queue

C ) List

D ) Link list

Answer : A

19. Representation of data structure in memory is known as

A ) recursive

B ) abstract data type

C ) storage structure

D ) file structure

Answer : B

20. A linear collection of data elements where the linear node is given by means of pointer is called

A ) linked list

B ) node list

C ) primitive list

D ) None of these

Answer : A

“AtoZ Telugu News –Mobile App”


PRACTICE TEST-2

1. A characteristic of the data that binary search uses but the linear search ignores is the___________.

A ) Order of the elements of the list

B ) Length of the list

C ) Maximum value in list

D ) Type of elements of the list

Answer : A

2. An algorithm is made up of two independent time complexities f (n) and g (n). Then the complexities
of the algorithm is in the order of

A ) f(n) x g(n)

B ) Max (f(n),g(n))

C ) Min (f(n),g(n))

D ) f(n) + g(n)

Answer : B

3. Which of the following is not a limitation of binary search algorithm?

A ) Must use a sorted array

B ) Requirement of sorted array is expensive when a lot of insertion and deletions are needed

C ) There must be a mechanism to access middle element directly

D ) Binary search algorithm is not efficient when the data elements are more than 1000

Incorrect

Answer : D

4. The largest element of an array index is called its

A ) lower bound

B ) range
“AtoZ Telugu News –Mobile App”
C ) upper bound

D ) All of these

Answer : C

5. The goal of hashing is to produce a search that takes

A ) O(1) time

B ) O(n2 ) time

C ) O(log n ) time

D ) O(n log n ) time

Answer : A

6. The best average behaviour is shown by

A ) Quick Sort

B ) Merge Sort

C ) Insertion Sort

D ) Heap Sort

Answer : A

7. Which of the following data structures are indexed structures?

A ) linear arrays

B ) linked lists

C ) both of above

D ) none of above

Answer : A

8. The extra key inserted at the end of the array is called as,

A ) End key

“AtoZ Telugu News –Mobile App”


B ) Stop key

C ) Sentinel

D ) Transposition

Answer : C

9. In Breadth First Search of Graph, which of the following data structure is used?

A ) Stack

B ) Queue

C ) Linked List

D ) None of the above

Answer : B

10. Consider that n elements are to be sorted. What is the worst case time complexity of Bubble sort?

A ) O(1)

B ) O(log2n)

C ) O(n)

D ) O(n2)

Answer : D

11. Which data structure is needed to convert infix notation to postfix notation?

A ) Branch

B ) Queue

C ) Tree

D ) Stack

Answer : D

12. A queue stores items in order of

“AtoZ Telugu News –Mobile App”


A ) FIFO (First In First Out) list

B ) LIFO (Last In First Out) list

C ) Ordered array

D ) Linear tree

Answer : A

13. What is the result of the following operation Top (Push (S, X))

A) X

B ) null

C) S

D ) None of these

Answer : A

14. The memory address of fifth element of an array can be calculated by the formula

A ) LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell


for the array

B ) LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell


for the array

C ) LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell


for the array

D ) None of above

Answer : A

15. The memory address of the first element of an array is called

A ) Floor address

B ) Foundation address

C ) First address

D ) Base address

“AtoZ Telugu News –Mobile App”


Answer : D

16. What is the postfix form of the following prefix *+ab–cd

A ) ab+cd–*

B ) abc+*–

C ) ab+*cd–

D ) ab+*cd–

Answer : A

17. Which of the following is not the required condition for binary search algorithm?

A ) The list must be sorted

B ) There should be the direct access to the middle element in any sublist

C ) There must be mechanism to delete and/or insert elements in list

D ) None of above

Answer : C

18. Two dimensional arrays are also called

A ) Tables arrays

B ) Matrix arrays

C ) Both of above

D ) None of above

Answer : C

19. Which of the following operations is performed more efficiently by doubly linked list than by singly
linked list?

A ) Deleting a node whose location in given

B ) Searching of an unsorted list for a given item


“AtoZ Telugu News –Mobile App”
C ) Inverting a node after the node with given location

D ) Traversing a list to process each node

Answer : A

20. An ADT is defined to be a mathematical model of a user-defined type along with the collection of all
____________ operations on that model.

A ) Cardinality

B ) Assignment

C ) Primitive

D ) Structured

Answer : C

practice Test - 3

1. Which of the following data structure can’t store the non-homogeneous data elements?

A ) Arrays

B ) Records

C ) Pointers

D ) None

Answer : A

2. When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return

A ) FAEKCDBHG

B ) FAEKCDHGB

C ) EAFKHDCBG

D ) FEAKDCHBG

Answer : B

“AtoZ Telugu News –Mobile App”


3. Consider the tree.If the post order travesal gives ab –cd * + then the label of the nodes 1, 2, 3, ….. will
be

A ) +, -, *, a, b, c, d

B ) a, -, b, +, c, *, d

C ) a, b, c, d, -, *, +

D ) -, a, b, +, *, c, d

Answer : A

4. The difference between linear array and a record is

A ) An array is suitable for homogeneous data but hte data items in a record may have different data
type

B ) In a record, there may not be a natural ordering in opposed to linear array

C ) A record form a hierarchical structure but a linear array does not

D ) All of above

Answer : D

5. Which of the following data structure store the homogeneous data elements?

A ) Arrays

B ) Records

C ) Pointers

D ) None

Answer : B

6. Which of the following statement is false?

A ) Arrays are dense lists and static data structure

B ) Data elements in linked list need not be stored in adjacent space in memory

C ) Pointers store the next data element of a list

D ) Linked lists are collection of the nodes that contain information part and next

“AtoZ Telugu News –Mobile App”


Incorrect

Answer : C

7. A binary tree in which every non-leaf node has non-empty left and right subtrees is called a strictly
binary tree. Such a tree with 10 leaves

A ) Cannot have more than 19 nodes

B ) Has exactly 19 nodes

C ) Has exactly 17 nodes

D ) Cannot have more than 17 nodes

Answer : B

8. Each data item in a record may be a group item composed of sub-items; those items which are
indecomposable are called

A ) Elementary items

B ) Atoms

C ) Scalars

D ) All of above

Answer : D

9. Which of the following name does not relate to stacks?

A ) FIFO lists

B ) LIFO list

C ) Up-down lists

D ) Push-down lists

Answer : A

10. The complexity of linear search algorithm is

A ) O(n)

“AtoZ Telugu News –Mobile App”


B ) O(logn)

C ) O(n2)

D ) O(nlogn)

Answer : A

11. The situation when in a linked list START=NULL is

A ) Underflow

B ) Overflow

C ) Houseful

D ) Saturated

Answer : A

12. When new data are to be inserted into a data structure, but there is no available space; this situation
is usually called

A ) Underflow

B ) Overflow

C ) Housefull

D ) Saturated

Answer : B

13. The term “push” and “pop” is related to the

A ) Array

B ) Lists

C ) Stacks

D ) All of above

Answer : C

14. A data structure where elements can be added or removed at either end but not in the middle
“AtoZ Telugu News –Mobile App”
A ) Linked lists

B ) Stacks

C ) Queues

D ) Deque

Answer : D

15. Which of the following is not a linear data structure?

A ) Arrays

B ) Linked list

C ) Both of these

D ) None of these

Answer : D

16. Two main measures of the efficiency of an algorithm are

A ) Processor and memory

B ) Complexity and capacity

C ) Time and space

D ) Data and space

Answer : C

17. Binary search algorithm cannot be applied to

A ) Sorted linked list

B ) Sorted binary trees

C ) Sorted linear array

D ) Pointer array

Answer : A

“AtoZ Telugu News –Mobile App”


18. The time factor when determining the efficiency of algorithms is measured by

A ) Counting microseconds

B ) Counting the number of key operations C ) Counting the number of operations

D ) Counting the kilobytes of an operation

Answer : B

19. A variable P is called pointer if

A ) P contains the address of an element in DATA

B ) P points to the address of first element in DATA

C ) P can store only memory addresses

D ) P contain the DATA and the address of DATA

Answer : A

20. Which of the following is a two way list?

A ) Grounded header list

B ) Circular header list

C ) Linked list with header and trailer nodes

D ) None of above

Answer : D

…………………………………..The End…………………………………..

…………………………………All The Best…………………………………………

“AtoZ Telugu News –Mobile App”

Potrebbero piacerti anche