QB DataStructures
QB DataStructures
PART A
5. What is abstract data type? What are all not concerned in an ADT?
The abstract data type is a triple of D i.e. set of axioms, F-set of functions and A-Axioms in
which only what is to be done is mentioned but how is to be done is not mentioned. Thus ADT is not
concerned with implementation details.
6. List out the areas in which data structures are applied extensively.
Following are the areas in which data structures are applied extensively.
Operating system - the data structures like priority queues are used for scheduling the jobs
in the operating system.
Compiler design - the tree data structure is used in parsing the source program. Stack data
structure is used in handling recursive calls.
Data Structures
Database management system- The file data structure is used in database management
systems. Sorting and searching techniques can be applied on these data in the file.
Numerical analysis package- the array is used to perform the numerical analysis on the
given set of data.
Graphics- the array and the linked list are useful in graphics applications.
Artificial intelligence- the graph and trees are used for the applications like building
expression trees, game playing.
The singly linked list has only forward pointer and no backward link is provided. Hence the
traversing of the list is possible only in one direction. Backward traversing is not possible.
Insertion and deletion operations are less efficient because for inserting the element at
desired position the list needs to be traversed. Similarly, traversing of the list is required for
locating the element which needs to be deleted.
12. State the properties of LIST abstract data type with suitable example.
Various properties of LIST abstract data type are
1. It is linear data structure in which the elements are arranged adjacent to each other.
2. It allows to store single variable polynomial.
3. If the LIST is implemented using dynamic memory then it is called linked list. Example of
LIST are- stacks, queues, linked list.
13. State the advantages of circular lists over doubly linked list.
In circular list the next pointer of last node points to head node, whereas in doubly linked list
each node has two pointers: one previous pointer and another is next pointer. The main advantage of
Data Structures
circular list over doubly linked list is that with the help of single pointer field we can access head
node quickly. Hence some amount of memory get saved because in circular list only one pointer is
reserved.
14. What are the advantages of doubly linked list over singly linked list?
The doubly linked list has two pointer fields. One field is previous link field and another is
next link field. Because of these two pointer fields we can access any node efficiently whereas in
singly linked list only one pointer field is there which stores forward pointer.
20. What is static linked list? State any two applications of it.
1.The linked list structure which can be represented using arrays is called static linked list.
2.It is easy to implement, hence for creation of small databases, it is useful
3.The searching of any record is efficient, hence the applications in which the record need to be
searched quickly, and the static linked list are used.
PART B
1. Explain the insertion operation in linked list. How nodes are inserted after a specified node.
2. Write an algorithm to insert a node at the beginning of list?
3. Discuss the merge operation in circular linked lists.
Data Structures
4. What are the applications of linked list in dynamic storage management?
5. How polynomial expression can be represented using linked list?
6. What are the benefit and limitations of linked list?
7. Define the deletion operation from a linked list.
PART C
Data Structures
UNIT-II LINEAR DATA STRUCTURE – STACK AND QUEUE
Stack – Operations, Array and Linked list implementation, Applications – Evaluation of Arithmetic
Expressions, Queues- Operations, Array and Linked list Implementation.
PART A
1. Define Stack
A Stack is an ordered list in which all insertions (Push operation) and deletion (Pop
operation) are made at one end, called the top. The topmost element is pointed by top. Stack is also
referred as Last in First out (LIFO) list.
6. Define Queue.
A Queue is an ordered list in which all insertions take place at one end called the rear, while
all deletions take place at the other end called the front. Rear is initialized to -1 and front is
initialized to 0. Queue is also referred as First In First Out (FIFO) list.
Data Structures
9. Define Dequeue.
Dequeue stands for Double ended queue. It is a linear list in which insertions and deletion are
made from either end of the queue structure.
PART B
1. Write an algorithm for Push and Pop operations on Stack using Linked list.
2. Explain the linked list implementation of stack ADT in detail?
3. Define an efficient representation of two stacks in a given area of memory with n words and
explain.
4. Explain linear linked implementation of Stack and Queue?
5. Write an ADT to implement stack of size N using an array. The elements in the stack are to be
integers. The operations to be supported are PUSH, POP and DISPLAY. Take into account the
exceptions of stack overflow and stack underflow.
6. A circular queue has a size of 5 and has 3 elements 10, 20 and 40 where F=2 and R=4. After
inserting 50 and 60, what is the value of F and R. Trying to insert 30 at this stage what happens?
Delete 2 elements from the queue and insert 70, 80 & 90.
7. Show the sequence of steps with necessary diagrams with the value of F & R.
8. Write the algorithm for converting infix expression to postfix (polish) expression?
9. Explain in detail about priority queue ADT in detail?
10. Write a function called ‘push’ that takes two parameters: an integer variable and a stack into
which it would push this element and returns a 1 or a 0 to show success of addition or failure.
PART C
Data Structures
UNIT-III NONLINEAR DATA STRUCTURE –TREES
Tree Terminologies, Binary Tree Representation, Tree Traversals, Binary Search Trees, Binary
Heap, Height Balance Trees – AVL Trees.
PART A
1. Define Tree?
Trees are non-liner data structure, which is used to store data items in a shorted sequence.
It represents any hierarchical relationship between any data Item. It is a collection of nodes, which
has a distinguish node called the root and zero or more non-empty sub trees T1, T2,….Tk. each of
which are connected by a directed edge from the root.
5. Define sibling?
Nodes with the same parent are called siblings. The nodes with common parents are called
siblings.
17. List out the steps involved in deleting a node from a binary search tree.
• Deleting a node is a leaf node (ie) No children
• Deleting a node with one child.
• Deleting a node with two Childs.
Data Structures
18. What is ‘B’ Tree?
A B-tree is a tree data structure that keeps data sorted and allows searches, insertions, and
deletions in logarithmic amortized time. Unlike self-balancing binary search trees, it is optimized for
systems that read and write large blocks of data. It is most commonly used in database and file
systems.
PART B
1. Explain the AVL tree insertion and deletion with suitable example.
2. Describe the algorithms used to perform single and double rotation on AVL tree.
3. Explain about B-Tree with suitable example.
4. Explain about B+ trees with suitable algorithm.
5. Write short notes on
i. Binomial heaps
ii. Fibonacci heaps
6. Explain the tree traversal techniques with an example.
7. Construct an expression tree for the expression (a+b*c) + ((d*e+f)*g). Give the outputs when
you apply inorder, preorder and postorder traversals.
8. How to insert and delete an element into a binary search tree and write down the code for the
insertion routine with an example.
PART C
1. What are threaded binary tree? Write an algorithm for inserting a node in a threaded binary
tree.
2. Create a binary search tree for the following numbers start from an empty binary search tree.
45,26,10,60,70,30,40 Delete keys 10, 60 and 45 one after the other and show the trees at each
stage.
Data Structures
UNIT-IV NONLINEAR DATA STRUCTURE –GRAPH
Representation of Graphs, Topological Sort, Depth First Search and Breadth-First Search,
Minimum Spanning Tree – Prim's Algorithm, Shortest path algorithm – Dijikstra’s Algorithm.
PART A
2. Define Graph?
A graph G consist of a nonempty set V which is a set of nodes of the graph, a set E which is
the set of edges of the graph, and a mapping from the set of edges E to set of pairs of elements of V.
It can also be represented as G = (V, E).
7. What is a loop?
An edge of a graph, which connects to itself, is called a loop or sling.
Data Structures
23. Define biconnected graph?
A graph is called biconnected if there is no single node whose removal causes the graph to
break into two or more pieces. A node whose removal causes the graph to become disconnected is
called a cut vertex.
24. What are the two traversal strategies used in traversing a graph?
a. Breadth first search
b. Depth first search
PART B
1. Explain the adjacency matrix and adjacency list representations of graphs with examples.
2. What is topological sorting? Explain the algorithm with an example of a Directed Acyclic
Graph (DAG).
3. Describe the Depth-First Search (DFS) algorithm and illustrate its working with an
example.
4. Explain the Breadth-First Search (BFS) algorithm and provide an example.
5. Explain Prim’s algorithm for finding the Minimum Spanning Tree of a graph with an
example.
6. Describe Dijkstra’s algorithm for finding the shortest path in a weighted graph with an
example.
PART C
1. Describe the steps involved in performing a topological sort. Apply the algorithm to a
sample DAG.
2. Discuss the advantages and disadvantages of different graph representations (adjacency
matrix, adjacency list). Provide examples.
3. Compare Prim's and Dijkstra's algorithms in terms of purpose, approach, and complexity.
Provide suitable examples.
Data Structures
UNIT-V SORTING AND HASHING
Sorting Techniques –Insertion Sort, Quick Sort, Merge Sort, Hashing- Hashing functions – Mid
square, Division, Folding, Collision Resolution Techniques – Separate Chaining – Open Addressing
– Rehashing.
PART A
4. What operation does the insertion sort use to move numbers from the unsorted section to the
sorted section of the list?
The Insertion Sort uses the swap operation since it is ordering numbers within a single list.
5. How many key comparisons and assignments an insertion sort makes in its worst case?
The worst case performance in insertion sort occurs when the elements of the input array are
in descending order. In that case, the first pass requires one comparison, the second pass requires two
comparisons, third pass three comparisons,….kth pass requires (k-1), and finally the last pass requires
(n-1) comparisons. Therefore, total numbers of comparisons are:
f(n) = 1+2+3+………+(n-k)+…..+(n-2)+(n-1) = n(n-1)/2 = O(n2)
9.Which of the following sorting methods would be especially suitable to sort a list L consisting
of a sorted list followed by a few “random” elements?
Quick sort is suitable to sort a list L consisting of a sorted list followed by a few “random”
elements.
10. What is the output of quick sort after the 3rd iteration given the following sequence?
24 56 47 35 10 90 82 31
Pass 1:- (10) 24 (56 47 35 90 82 31)
Pass 2:- 10 24 (56 47 35 90 82 31)
Pass 3:- 10 24 (47 35 31) 56 (90 82)
PART B
PART C
1. Show the result of inserting the keys 2, 3, 5,7,11,13,15,6,4 into an initially empty extendible
hashing data structure with M=3.
2. What are the advantages and disadvantages of various collision resolution strategies?
3. Explain the Quick Sort algorithm in detail and demonstrate its working with an example.
Data Structures
4. Describe the Merge Sort algorithm using the divide-and-conquer approach and illustrate it
with a numerical example.
5. What are hashing functions? Explain Mid Square, Division, and Folding methods with
suitable examples.
6. Discuss collision resolution techniques in hashing, including Separate Chaining and Open
Addressing, with examples.
Data Structures