You are on page 1of 16

VELAMMAL ENGINEERING COLLEGE

DEPARTMENT OF ECE
DATA STRUCTURES AND ALGORITHMS
Question bank
Unit-1
1. Which type of Linked List does not store null in the next field?

a) Single linked list


b) Double Linked List
c) Circular Linked List
d) None of the above
2. Linked list is used to implement data structures like _________
a) stack
b) queue
c) tree
d) all the above
3. which type of linked list stores the address header node in the next field of the last
node?
a) Circular Linked List
b) Double Linked List
c) Single Linked list
None of the above
4. Linked list is considered as an example of _________type of memory allocation
a) static
b) dynamic
c)compile time
d)Heap
5.What is the time complexity of insertion and deletion of beginning of array?
a) O(n)
b) O(logn)
c) O(n2)
d)O(nlogn)
6. Which of the following is not the part of ADT description?
a)Data b)Operations c)Data and Operations d)None
7.To create a linked structure, each node must have one member, which is ____
a) A pointer to the head of the list
b) A pointer to NULL
c) A pointer to the node type
d) A reference to the element type
8. A variant of the linked list in which none of the node contains NULL pointer is?

a) Singly linked list


b) Doubly linked list
c) Circular linked list
d) None
9. Which of the following statement is true, if a polynomial expression with high power
is implemented using array?
a)wastage of time only
b)wastage of memory only
c)wastage of both time and memory
d)none
10. 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));
11. Identify the application of list ADT.
a)convert of infix expression to postfix expression
b)Polynomial Operations
c)Printer waiting Job list
d)Balancing symbols
12 In linked list each node contains 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.

PART B
1.List out the application of Linked list.
2. Summarize any two issues in array-based implementation of list ADT.
3.State the difference between arrays and linked lists.
4. List the basic operations carried out in a linked list.

5. What are the benefits of ADT.


6. State the differences between linear linked list and circular linked list.
7. What are the advantages of doubly linked list over singly linked list?
8. Define an Abstract Data Type (ADT).
9. List out the disadvantages of using a doubly linked list

10. List out the advantages and disadvantages of using a linked list

PART C
1. Write routines to delete a node at middle and end of a list implemented with doubly
linked list. (7)
2. Explain the operation of deletion (beginning and end) in array-based list with
procedure and suitable examples. (7)
3. Write routines to insert a node at middle and end of a list implemented with doubly
linked list. (7)
4. Explain the operation of insertion (beginning and end) in array-based list with
procedure and suitable examples. (7)
5. Write a routine for Creation ,insertion, deletion using doubly linked list.(14)

Note:
✓ Study all the routines of Insertion, deletion using singly and doubly
linked list
✓ Creation- singly linked list)
UNIT 2
MCQ
1. In a stack, if a user tries to remove an element from an empty stack it is called
_________
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection
2. The circular queue will be full only when
a) FRONT = MAX-1 and REAR = MAX-1
b) FRONT = 0 and REAR = MAX-1
c) FRONT = MAX-1 and REAR = 0
d) FRONT = 0 and REAR = 0
3. What is the term for inserting into a full queue known as?
a) null pointer exception
b) underflow
c) overflow
d) program won’t be compiled
4. 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 /
5.Queue follows?
a) FIFO b) LIFO c)FILO d)LILO
6. Stack follows?
a) FIFO b) LIFO c)FILO d)LILO
7. 3) If stack is full, top=?
a) size b) size-1 c) 1 d)0
8.If stack is empty, top=?
a) 0 b) 1 c) -1 d) none
9. Stack can be implemented using _________ and ________?
a) Array and Binary Tree b) Linked List and Graph
c) Array and Linked List d) Queue and Linked List
10. Insertion and Deletion operation in Queue is known as ?

Push and Pop


Enqueue and Dequeue
Insert and Delete
None
11.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) (A B D E F + ⋀ / – G +)
12. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, *
is?
a) 600 b)350 c)650 d)588
13. Circular Queue is also known as ________
a) Ring Buffer b) Square Buffer c) Rectangle Buffer d) Curve Buffer
14. ------------------operation is done during Stack Underflow condition
a) Deletion b) Pop c)Push d)Peek
15. The term Push and Pop is related to
a)Queue b) Stack c) Both d) Circular Queue
16. Queue is
a) Non-primitive, Linear , Dynamic, LIFOdata structure
b) Non-primitive, Non-Linear , Static,FIFO data structure
c) Non-primitive, Non-Linear , Static, LIFOdata structure
d) Non-primitive, Linear , Dynamic, FIFOdata structure

17. What is the need for a circular queue?


a) effective usage of memory
b) easier computations
c) to delete elements based on priority
d) implement LIFO principle in queues
PART B
1. Write a Routine to test whether a stack is empty.
2. What are the applications of queues
3. List the operations of queue.
4. State the rules to be followed during infix to postfix conversions
5. Brief about the operations on stack.
6. Define Circular queue
7. What is the advantage of circular queue over linear queue.
8. List out the basic operations that can be performed on a stack.
9. Define a stack.
10. Illustrate the different ways of representing expressions
11. Convert infix to postfix notation
A+B*(C-D)/(P-R)
12.What are the disadvantages of Queue? Or What is the reason we are going
for circular queue?
13. Convert the following infix expression to postfix expression using
stack. a+b*c+(d+e+f)/g
14. What is the advantage of circular queue over linear queue.
PART C
1.Write a routine with an example En queue (insertion) and dequeue(deletion) operation
using array.
2. Write the procedure to convert infix expression to postfix expression and steps involved in
evaluating the postfix expression. Convert the expression A-(B/C+D%E*F)/G*H to postfix form.
Evaluate the postfix expression 934*8+4/-.

3. Explain circular queue and its implementation using array.

4. Write an routine for enqueue and dequeue operations using a linked list with example.

5. Demonstrate the deletion of an element in queue with an example.


6. Evaluate the following expression using stack:
12 + 3 * 14 – (5 * 16) + 7

7.What are the limits of Linear Queue?How to overcome using circular Queue?Explain the
operations of enqueue and dequeue in circular queue.
8. Write an routine for push and pop operations using stack with example.
UNIT 3
MCQ
1. Total number of nodes at the nth level of a binary tree can be given as
a)2h
b)2(h+1)-1
c)2h
d) 2(h-1)-1
2. For the expression (2-(6*8))+(1/4) which of the following is the post order tree
traversal?
a) 268*-14/+
b) 14/+268*-
c) *268-14/+
d) 26*+814/-
3. In which traversal, first the parent is visited, then the left child and finally the right
child?
a) Inorder traversal
b) Level order traversal
c) Postorder traversal
d) Preorder traversal
4. Why we need to a binary tree which is height balanced?
a) to avoid formation of skew trees
b) to save memory
c) to attain faster memory access
d) to simplify storing
5. Which is not a type of binary tree
a) skewed b) complete c) perfect d) level
6. Interior node is means node at least with _____ child
a) 0 b) 1 c) 2 d) 3
7. Parent is also called as
a) descendants b) ansister c) node d) branch
8. To represent hierarchical relationship between elements, which data structure
is suitable?
a) Dequeue b) Priority c) Tree d) Graph
9. 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
10.What is the worst case time complexity of inserting n2 elements into an AVL-tree with n
elements initially?
a) O(n) b) O(n2) c)O(n2 log n) d)O(n3)
11.AVL tree is a self-balancing Binary Search Tree (BST) where the difference between
heights of left and right sub trees cannot be more than one for all nodes.
12. 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) A tree In which all nodes have degree 2
13. Which of the following is incorrect 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) Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N
+ 1))

14. What is the average case 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)

15. If the size of the stack is 10 and we try to add the 11th element in the stack then the condition
is known as___

a. Garbage collection
b. Overflow
c. underflow
d. None of the above

16. Why a binary tree is needed to be height balanced?


a)To avoid formation of skew trees
b)To save memory
c)To attain faster memory access

d)To simplify storing

Part B
1. The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e
cf g respectively. Show the post order traversal of the binary tree.
2. What do you mean by articulation point?
3. Represent the expression A + B * (C-D) / E as a binary tree.
4. Differentiate between binary search tree and AVL tree.
5. What are the types of AVL Rotation?
6. The number of rotations required to insert a sequence of elements 9,6,5,8,7,10 into an
AVL tree is? Ans:3 rotation (need to proof)
7. State the properties of a binary tree and AVL tree.
8. What are the different binary tree traversal techniques?
9. Define AVL Tree. Give Example.
10. When AVL tree property is violated and how to solve it?
11. Define Rotation in AVL tree. Mention the two types of rotations.
12. What are the tasks performed during post-order traversal?
13. Depth of a complete binary tree is 8, compute the number of nodes in leaf.
14. Define height of the binary tree
Part C
1. Explain the different types of AVL rotations with an example. (14)
2. Construct an AVL Tree by inserting the following elements in the given order
63,9,19,27,18,108,99,81 (14)
3. What is the impact of Balanced factor?Construct an AVL Tree by inserting the following
elements in the given order 2,1,4,5,9,3,6,7 (14)
4. i)Explain the various cases to delete a node in a binary search tree with routines and

suitable diagrams. (7)


ii) Insert 16,22,18,15,10,16,4,29,27,23,11,25,26 into an initially empty binary search tree.
(7)
5.i) Illustrate insertion of a node in a binary search tree with an example. (7)
ii) Construct an expression tree for the expression (a + b * c) + ((d * e + 1) * g). Give the
outputs when you apply preorder, inorder and postorder traversals
6.(Be thorough with AVL tree problem.) Construct an AVL Tree by inserting the
following elements in the given order 3,2,1,4,5,6,7,16,15,14,13,12,11,10
7. Consider the binary search tree given below.
Find the result of in-order, pre-order, and post-order traversals.
Insert 11, 22, 33, 44, 55, 66, and 77 in the tree

8.Write the following routines to implement the basic binary search tree operations.
(i) Perform Search operations in BST
(ii) Find _ min and Find_ max

Note:
Be thorough AVL and BST
UNIT 4
MCQ
1. An adjacency matrix representation of a graph cannot contain information of

a) Nodes
b) Edges
c) Direction of edges
d) Parallel edges
2. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) N
d) Information given is insufficient
3. 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
4. Consider a complete graph G with 4 vertices. The graph G has ____ spanning trees.

a) 15
b) 8
c) 16
d) 13
5. Every vertex should have a connection with every other
a) complete graph b) connected graph c) directed graph d) undirected graph
6. Dijkstra’s Algorithm is used to solve _____________ problems.
a) All pair shortest path
b) Single source shortest path
c) Network flow
d) Sorting
7. Which of the following ways can be used to represent a graph?
a) Adjacency List and Adjacency Matrix
b) Incidence Matrix
c) Adjacency List, Adjacency Matrix as well as Incidence Matrix
d) No way to represent
8. Prim’s algorithm is a ______
a) Divide and conquer algorithm
b) Greedy algorithm
c) Dynamic Programming
d) Approximation algorithm
9. Topological sort can be applied to which of the following graphs?
a) Undirected Cyclic Graphs
b) Directed Cyclic Graphs
c) Undirected Acyclic Graphs
d) Directed Acyclic Graphs
10. Topological sort is equivalent to which of the traversals in trees?
a) Pre-order traversal
b) Post-order traversal
c) In-order traversal
d) Level-order traversal
11. Which of the following data structure is required to convert arithmetic expression in infix
to its equivalent postfix notation?
a) Queue
b) Linked list
c) Binary search tree
d) None of above
12. Find the total number of spanning trees with 4 vertices that can be created from a
complete graph
a)13
b)14
c)15
d)16
13. 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
14. The number of elements in the adjacency matrix of a graph having 7 vertices
is_________
a)7 b) 21 c)36 d)49
PART B

1.What is a directed graph and undirected graph?

2.What is meant by strongly connected in a graph?

3.Difference between direct and undirected gragh.

4. Define spanning tree .Give an example.

5. What are the tasks performed during preorder traversal?


6. Define topological sorting.
7. What is a weighted graph?
8. Name the different ways of representing a graph?

9. What is an undirected acyclic graph?

10.Define minimum spanning tree.

11.Define expression tree.

12.Write the application of Topological sort


13.What are the uses of Dijkstra’s algorithm?

PART C

1. Consider the graph given below. Find the minimum spanning tree of the graph using Prims
Algorithm (14)

2. Explain the topological sorting of a graph G with example (14)


3. Explain the following algorithms with routines and example
i)Prim’s algorithm.
ii) Topological sorting
4. Consider the graph given below. Find the minimum spanning tree of the graph using kruskals
Algorithm (values will change) (14)

5
1 2
3
1 2 2 5
6
3 4 4

5.Explain the following with examples (14)


i)Adjacency Matrix representation
ii)Adjacency List representation
6. Consider the given graph. Determine the shortest distance from A to all other nodes using
Dijkstra’s algorithm. (see the concept fully) Values will change
Note:
PRIMS AND KRUSKALS BE THOROUGH

UNIT V
MCQ
1.The complexity of a linear search algorithm _________
a)O(n)
b)O(logn)
c)O(n2)
d)O(nlogn)
2. Two main measures of the efficiency of an algorithm are
a) Processor and Memory
b) Complexity and capacity
c) Time and Space
d) Date and Space

3. Consider a complete graph G with 4 vertices. The graph G has ____ spanning trees.

a) 15
b) 8
c) 16
d) 13
4. The travelling salesman problem can be solved using _________
a) A spanning tree
b) A minimum spanning tree
c) Bellman – Ford algorithm
d) DFS traversal
5.Which of the following is not a big-O notation?
a)O(n)
b)Ω(n)
c)Theta(n)
d)f(n)
6.The time complexity of a bottom up approach in Fibonacci series_________
a)O(n)
b)O(logn)
c)O(n2)
d)O(nlogn)
7. Recurrence relation is involved in_________
a)greedy method
b)divide and conquer
c)branch and bound
d)randomized algorithms
PART B
1. What is randomized algorithm?
.
2. State the principle of branch and bound algorithms.

3. State the principle of backtracking.


4. Differentiate Dynamic Programming from Divide and Conquer.

5. What are the applications of greedy method?


6. Write any asymptotic notations?
7.Give some examples of Greedy algorithms.
8. What is recurrences?
9. List any two applications that use greedy algorithms.
10.Explain Omega Notation, Ω in asymptotic notations?

PART C
1. .i) Discuss the NP complete problem with an example (7)
ii) Solve the following recurrence relation using substitution method
T(n)=T(n-1)+1 (7)

2. How is Branch and Bound technique used in the designing of algorithms and
explain with knapsack problem. (14)
3. Explain Divide and Conquer technique(Merge sort) in the designing of algorithms with
a clear procedure and suitable example
4. Explain the backtracking problem using 5-queen Problem.(14)
5. Demonstrate the different kinds of algorithm for designing to solve the
problem.(14)
6. How is Branch and Bound technique used in the designing of algorithms and explain
with Travelling Salesman problem.
7. Using Floyd Warshall’s algorithm finds the shortest path between all pair of node for the
following graph.

8. Explain the working of merge sort on the following data.


10,15,0,17,20,25,30,16,70,6.Write the pseudo code for the merge sort.

9.Explain Convex Hull using divide and conquer method

You might also like