Professional Documents
Culture Documents
(Data Structures)
Vijay Kumar Dwivedi
Assistant Professor
UCER, Prayagraj
Mobile: 9235668045
Email: vijay.kr.dwivedi@gmail.com
Question 1
Tell how to check that linked list is circular?
Question 1
Tell how to check that linked list is circular?
Ans:
• A linked list is called circular if it is not NULL-
terminated and all nodes are connected in the
form of a cycle.
R-R Rotation
Question 20 Contd...
Explain different type of rotations in AVL
Ans: L-R Rotation
Question 20 Contd...
Explain different type of rotations in AVL
Ans: R-R Rotation
Question 21
What is Collision?
Question 21
What is Collision?
Ans:
Since a hash function gets us a small number
for a key which is a big integer or string, there
is a possibility that two keys result in the same
value.
The situation where a newly inserted key
maps to an already occupied slot in the hash
table is called collision
It must be handled using some collision
handling technique.
Question 22
Different type of Collision Resolution
Technique?
Question 22
Different type of Collision Resolution
Technique?
Ans: Mainly two methods to handle collision:
1) Separate Chaining
The idea is to make each cell of hash table point to a linked
list of records that have same hash function value.
2) Open Addressing
Linear Probing: In linear probing, we linearly probe for next
slot.
Quadratic Probing We look for i2‘th slot in i’th iteration.
Double Hashing We use another hash function hash2(x)
Question 25
Differentiate between DFS and BFS?
Question 25
Question 26
What is Spanning Tree?
Question 26
What is Spanning Tree?
Ans:
A spanning tree is a subset of Graph G,
which has all the vertices covered with
minimum possible number of edges.
Hence, a spanning tree does not have
cycles and it cannot be disconnected..
Question 27
What are the various operations
that can be performed on
different Data Structures?
Question 27
What are the various operations that can
be performed on different Data
Structures?
Ans:
1. Traversing
2. Searching
3. Inserting
4. Deleting
5. Sorting
6. Merging
Question 28
What is Stack and where it can be used?
Question 28
What is Stack and where it can be used?
Ans:
A stack is defined by having a LIFO (Last In First Out)
ordering principle. The first element added to a stack
is the last to be removed. Equivalently, the last
element added to a stack is the first to be removed.
Operations that act on a stack have a unique
terminology:
Push - add a new element to the stack.
Pop - remove an element from the stack.
Uses of Stack - undo\redo operation in word
processors, Expression evaluation and syntax
parsing, etc.
Question 29
What is a Linked List and what are its
types?
Question 29
What is a Linked List and what are its
types?
Ans:
A Linked List is a linear data structure made up
of multiple node elements that are linked
together using pointers.
Linked Lists can be dynamic in size, and have
more optimal insertion and deletion than arrays.
There are four common types of Linked List:
Singly Linked List
Doubly Linked List
Circular Linked List
Doubly Circular Linked List
Question 30
How to implement a stack using queue?
Question 30
How to implement a stack using queue?
Ans:
In push operation, the new element is
always enqueued to q1.
In pop() operation, if q2 is empty then
all the elements except the last, are
moved to q2.
Finally the last element is dequeued
from q1 and returned.
Question 31
Define Binary Search Tree?
Question 31
Define Binary Search Tree?
Ans: A binary search tree (BST) is a node
based binary tree data structure which has the
following properties.
• The left subtree of a node contains only nodes
with keys less than the node’s key.
• The right subtree of a node contains only nodes
with keys greater than the node’s key.
• Both the left and right subtrees must also be
binary search trees.
Question 32
What are different methods of Traversing a
Binary Tree?
Question 32
What are different methods of Traversing a
Binary Tree?
Ans:
InOrder Traversal
PreOrder Traversal
Post Order Traversal
Question 33
In Order Traversal ?
PreOrder Traversal ?
Post Order Traversal ?
Question 33
In Order Traversal
PreOrder Traversal
Post Order Traversal
Ans:
a) Inorder (Left, Root, Right) : 4 2 5 1 3
(b) Preorder (Root, Left, Right) : 1 2 4 5 3
(c) Postorder (Left, Right, Root) : 4 5 2 3 1