DSA - Question Bank
DSA - Question Bank
CSE II/III-B
UNIT I - INTRODUCTION
1. Define data structures.
An arrangement of data in a computer's memory or Way of organizing data in a computer so that it
can be used effectively
30. Write about Time Complexity Analysis of linear search and binary search
Linear search : The element being searched may be present at the last position or not present in the
array at all.In this case, the search terminates in success with n comparisons. Worst case, takes O(n)
operations.
Binary search: The element being searched by iteration or recursive call, where in each search gets
reduced to half of the array. There are log2n iterations or recursive calls.Worst case, takes O(log2n) operations
PART-B
PART-A
1. Array- kind of data structure that can store a fixed-size sequential collection of elements of the same type
3. Define a stack.
Stack is an ordered collection of elements in which insertions and deletions are restricted to one end called
top
4. List out the basic operations that can be performed on a stack and a queue.
The basic operations that can be performed on a stack and queue are,
Push operation
Pop operation
Peek operation
Empty check
Full occupied check
7. Define a queue.
Queue is an ordered collection of elements in which insertions and deletions take place in 2 ends. The end
from which elements are added referred to rear end, and the end from which deletions are made is referred
to as the front end.
9.Define a dequeue.
Dequeue(Double-ended queue) is another form of a queue in which insertions and deletions are made at both
the front and rear ends of the queue.
Circular Queues – Another form of linear queue in which the last position is connected to the first
position of the list
Double-Ended-Queue – Another form of queue in which insertions and deletions are made at both
the front and rear ends of the queue.
STACK QUEUE
Objects are inserted and removed from different
Objects are inserted and removed at the same end.
ends.
In stacks only one pointer is used. It points to the top
In queues, two different pointers are used for front
of the stack.
and rear ends.
In stacks, the last inserted object is first to come out. In queues, the object inserted first is first deleted.
Stacks follow Last In First Out (LIFO) order. Queues following First In First Out (FIFO) order.
Stack operations are called push and pop. Queue operations are called enqueue and dequeue.
Stacks are visualized as vertical collections. Queues are visualized as horizontal collections.
Collection of dinner plates at a wedding reception is People standing in a file to board a bus is an example
an example of stack. of queue.
In a Max Binary Heap, the key at root must be maximum among all keys present in Binary Heap. The
same property must be recursively true for all nodes in Binary Tree
21.Define Max Heap
In a Min Binary Heap, the key at root must be minimum among all keys present in Binary Heap. The
same property must be recursively true for all nodes in Binary Tree
PART- B
1. Write down and explain the operations performed in Stack ADT using array with its Algorithms and
their complexity analysis
2. Enumerate the Applications of Stacks with example
3. Explain briefly about the operations for enqueue and dequeue on queue ADT using array with its
Algorithms and their analysis
4. Explain the basic concept of Circular Queue Operations with example
5. With suitable examples explain the Priority Queue Operations with example
6. List and Explain various operation of Circular Queue with example
7. Explain infix to postfix expression and evaluating postfix expression with example. A*B+(C-D/E)
1. Define structure
Structure is a collection of variables belongings to the different data type. You can store group of
data of different data type in an array.
Eg : struct student
{
char name;
int roll no;
float m1,m2,m3;
};
2. Define pointer
A pointer is a variable whose value is the address of another variable, i.e., direct address of the
memory location. Like any variable or constant, you must declare a pointer before using it to store any
variable address. Eg :type *var-name;
3. Define dynamic memory allocation
The process of allocating memory at runtime is known as dynamic memory allocation. Library routines
known as "memory management functions" are used for allocating and freeing memory during execution
of a program. These functions are defined in stdlib.h.
Function Description
malloc() allocates requested size of bytes and returns a void pointer pointing to the first byte of the
allocated space
calloc() allocates space for an array of elements, initialize them to zero and then returns a void
pointer to the memory
7. State the different types of linked lists & different types of circular linked lists.
The different types of linked list include single linked list, double linked list and circular linked list.
The different types of circular linked list include circular singly linked list and circular doubly linked list.
15. Mention the advantages of representing stacks using linked lists than arrays.
It is not necessary to specify the number of elements to be sorted in a stack during its declaration
allocated dynamically at run time when an element is added to the stack).
Insertions and deletions can be handled easily and efficiently.
Linked list representation of stacks can grow and shrink in size
17. What are the steps to be involved while deleting a node in a singly linked list.
Find the position P before which the node has to be deleted i.e., find previous(X,L).
Change the link of the previous node to the link of the node to be deleted.
P->Next=P->Next->Next
18. What are the disadvantages of linear Queue? (CO2,K1)
C D E rear
front
In the above queue we have space but rear pointer points at end of the queue there fore we cannot
insert new element,which occurs memory wastage
(a+b*c)/d
a=2 b=4 c=6 d=2
Post fix:
abc*+d/
Evaluation:
2 4 6 * +2/
=13
PART-B
1. With suitable examples explain the operations performed on singly linked list. (CO1,K2)
2. Discuss about the operations performed on doubly linked list with example. (CO1,K2)
3. Explain the operations performed on Circular Doubly linked list with example. (CO1,K2)
4. Write short notes i. array and structure (8)
ii. pointer and recursion function (8)
5. Discuss the operations for push and pop operation on a stack ADT using linked list.
6. Enumerate the operations of queue ADT using linked list.
UNIT IV-TREES
PART-A
1. Define a tree.
A tree is a non-linear data structure, which represents hierarchical relationship between individual data items.
12. What is meant by binary tree traversal and list out the different binary tree traversal techniques
Traversing a binary tree, means moving through all the nodes in the binary tree, visiting each node in the tree
only once.
13. What are the tasks performed while traversing a binary tree?
The tasks performed while traversing a binary tree are,
Visiting a node.
Traverse the left subtree
Traverse the right subtree.
17. State the merits and demerits of linear representation of binary trees.
The merits of linear representation of binary trees includes
Storage method is easy and can be easily implemented in arrays.
It requires static memory allocation so it is easily implemented in all programming language.
The demerits of linear representation of binary trees includes,
Insertions and deletions in a node, taker an excessive amount of processing time, due to data
movement up and down the array.
18. State the merits and demerits of linked representation of a binary tree.
The merits of linked representation of binary trees includes
Insertions and deletions in a node, involves no data movement except the rearrangement of pointers,
hence less processing time.
The demerits of linked representation of binary trees includes,
Given a node structure, it is difficult to determine its parent node.
Memory spaces are wasted for storing null pointers for the nodes, which have one or no subtrees.
It requires dynamic memory allocation, which is not possible in some programming languages.
20. What are the basic operations performed in a binary search tree.
The basic operations performed in a binary search tree are,
Creation of a binary search tree
Insertion of a node
Deletion of a node.
Searching a node
View the contents of the binary search tree.
24.Write the Tree Traversals (Inorder, Preorder and Postorder) for a given tree.
(ii) Compute infix expression, prefix expression and postfix expression.( CO3,K3)
5. Discuss in detail about the operation Threaded Binary Tree
6. Illusrate B Tree operations with their algorithms with Complexity analysis.
7. With example explain the B+ Tree operation write the algorithms and its analysis
1. Define Hashing.
Hashing is the transformation of string of characters into a usually shorter fixed length value or key that
represents the original string. Hashing is used to index and retrieve items in a database because it is faster to
find the item using the short hashed key than to find it using the original value.
Linear probing is an open addressing collision resolution strategy in which F is a linear function of i,
F(i)=I 2. hi(x)=(Hash(x)+F(i))mod Tablesize . i=1,2,3,4…..
14. Consider given numbers { 50, 700, 76, 85, 92, 73, 101 }and hash function h(X)=X(mod 7).Find
the hash address of each number using separate chaining.
PART B