320 - CS8391 Data Structures - Important Questions
320 - CS8391 Data Structures - Important Questions
320 - CS8391 Data Structures - Important Questions
IMPORTANT QUESTIONS
Subject: CS8391-Data Structures Year/Sem:II/III
UNIT-I
PART-A
www.BrainKart.com
Click Here for Data Structures full study material.
Classes encapsulate all the essential properties of the objects that are to be
created. Since the classes use the concept of data abstraction, they are known as Abstract Data
Types (ADT).
Operations such as insertion and deletion Insertion and deletions are easier and needs
are ineffective since the memory locations only one pointer assignment.
need to be moved up and down
respectively.
PART-B
8. Write C code for singly linked list with insert, delete, display operations using structure
pointer.
9. Differentiate single linked list and doubly linked list with an example.
10. Explain the application of linked list in detail.
11. Consider an array A[1: n] Given a position, write an algorithm to insert an element in the
Array.If the position is empty, the element is inserted easily. If the position is already
occupied the element should be inserted with the minimum number of shifts.(Note: The
elementscan shift to the left or to the right to make the minimum number of moves).
www.BrainKart.com
Click Here for Data Structures full study material.
12. Analyze and write C code for circular linked list with create, insert,delete, display
operations.
13. Explain the various operations of the list ADT with examples.
14. Analyze the doubly linked list and circular linked list. Mention its advantages and
disadvantages.
15. Explain the steps involved in insertion and deletion into a singly linked list.
16. Recommend an algorithm to add two polynomials when the polynomials are
represented singly linked lists.
17. Compose an algorithm toReverse the elements of a single linked lists,count the number of
nodes in a given singly linked list. Searching the element from linked list.
18. Given an list 10,20,30,40 ,generalizethe steps to delete a node from the beginning of the
linked list, deletion of last node in adeletion of middle node in a list.
19. Develop a C program to split a linked list into sub lists containing odd and even ordered
elements in them respectively.
UNIT- 2
PART-A
1. Define stack?
Stack is an ordered collection of items into which new items may be inserted and from
which items may be deleted at one end, called the top of stack.
STACK QUEUE
Insertion and deletion are made at one end. Insertion at one end rear and deletion at
other end front.
The element inserted last would be The element inserted first would be
removed first. So LIFO structure. removed first. So FIFO structure.
Full stack condition: Full stack condition:
If(top==Maxsize) If(rear = = Maxsize)
Physically and Logically full stack Logically full. Physically may or may not
be full.
5. Define Dequeue.
A dequeue is an ordered list in which additions and deletions may be carried out at either end.
10. What are the limitations in the stack, when array used as home of stack?
The Array is finite collection of elements and in stack the number of elements is
unlimited. As the stack dynamically changes the attempts to insert more elements than the
array size cause overflow
12. What are the error conditions that could occur in stack implementation? How could they
be rectified?
Overflow
Underflow
To avoid overflow, the stack should be checked whether it is full or not before every push
operation.
To avoid underflow, the stack should be checked for emptiness before every
pop operation.
18. What are the basic operations that could be performed on a Queue?
Insertion – insert (q, x) inserts x at the rear end.
Removal – x=remove (q) remove the element in front end.
Empty(q) – Checks whether queue has any elements or not.
19. What are the limitations of linear queue? How they can be rectified?
When an element is removed from linear queue, the location remains unused. Even if the
queue is empty, new elements cannot be inserted. To avoid this, consider queue as a circle,
having the first element immediately following the last element.
21. What are the two types of priority queues? Briefly explain?
Two types of priority queues are,
i) Ascending priority queue – In this queue, the items can be inserted arbitrarily
and only the smallest item will be removed.
ii) Descending priority queue- This allows insertion of items arbitrarily, and only
the maximum element from queue will be removed first.
23. What are the limitations in priority queue? How it could be rectified?
Deletion of elements makes a location empty. The search of items includes the empty
spaces too. This takes more time. To avoid this, use an empty indicator or shift elements forward
when each element is deleted. We can also maintain priority queue as an array of ordered
elements, to avoid risk in searching.
a. 6 5 2 3 + 8 * + 3 + *2 3 1 * + 9 -
9. Briefly describe the operations of queue with example.
10. Describe about implementation of queue ADT using linked list. Give relevant examples
and diagrammatic representations.
11. Discuss and write a C program to implement queue functions using arrays.
12. Explain application of queue with suitable example.
13. Explain circular queue and its implementation.
14. Analyze the implementation of priority queue.
15. Prepare an algorithm to perform the operations in a double ended queue.Develop a C
program for linked list implementation of stack.
16. 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.Assess the
sequence of steps with necessary diagrams with the value of F & R.
17. Generalize and develop a function to insert an element into a queue and delete an
element from a queue, in which the queue is implemented as a linked list.
UNIT-III
PART-A
1. Define Tree.
A Tree is a collection of one or more nodes with a distinct node called the root , while
remaining nodes are partitioned as T1 ,T2, ..,Tk , K≥ 0 each of which are sub trees, the edges of
T1,T2,…,Tk are connected the root.
16. What are the tasks performed while traversing a binary tree?
Visiting a node
Traverse the left structure
Traverse the right structure.
20. Give the pre & postfix form of the expression (a + ((b*(c-e))/f).
Balanced search tree have the structure of binary tree and obey binary search tree properties
with that it always maintains the height as O(log n) by means of a special kind of rotations. Eg.
AVL, Splay, B-tree.
www.BrainKart.com
Click Here for Data Structures full study material.
A heap can be implemented as an array by recording its elements in the top-down, left-to-
right fashion. It is convenient to store the heap’s elements in positions 1 through n of such an
array. In such a representation
The parental node keys will be in the first n/2 positions of the array, while the leaf
keys will occupy the last n/2 positions
The children of a key in the array’s parental position ‘i’ (1 i n/2) will be in
positions 2i and 2i+1and correspondingly, the parent of the key in position ‘i’ (2
i n) will be in position i/2.
31. What are the two alternatives that are used to construct a heap?
The two alternatives to construct a heap are
Bottom-up heap construction
Top-down heap construction
33. What is the algorithm to delete the root’s key from the heap?
ALGORITHM
Exchange the root’s key with the last key K of the heap
Decrease the heap’s size by one
“Heapify” the smaller tree by sifting K down the tree exactly in the same way as
bottom-up heap construction. Verify the parental dominance for K: if it holds stop
the process, if not swap K with the larger of its children and repeat this operation
until the parental dominance holds for K in its new position.
A B-tree of order m in an m-way search tree that is either empty or is of height ≥1 and
1. The root node has at least 2 children
2. All nodes other than the root node and failure nodes have at least m/2 children.
3. All failure nodes are at same level.
PART-B
1. Write an algorithm for preorder, inorder and postorder traversal of a binary tree.
2. Explain the following operations on a binary search tree with suitable
algorithms
a. Find a node
b. Find the minimum and maximum elements of binary search tree.
3. Write an algorithm for inserting and deleting a node in a binary search tree.
4. Describe the concept of threaded binary tree with example.
5. Discuss in detail the various methods in which a binary tree can be represented. Discuss
theadvantage and disadvantage of each method.
UNIT - 4
PART-A
1. Define Graph.
A Graph G, consists of a set of vertices V, and a set of edges E.V is a finite non-empty set
consisting of vertices of vertices of the graph. The set of edges E consists of a pair of vertices
from the vertex set.
5 11
21. What is the use of Kruskal’s algorithm and who discovered it?
Kruskal’s algorithm is one of the greedy techniques to solve the minimum spanning
tree problem. It was discovered by Joseph Kruskal when he was a second-year graduate student.
23. Prove that the maximum number of edges that a graph with n Vertices is
n*(n-1)/2.
Choose a vertex and draw edges from this vertex to the remaining n-1 vertices. Then, from
these n-1 vertices, choose a vertex and draw edges to the rest of the n-2 Vertices. Continue
this process till it ends with a single Vertex.
Hence, the total number of edges added in graph is
(n-1)+(n-2)+(n-3)+…+1 =n*(n-1)/2.
PART-B
1. Examine topological sorting of a graph G with suitable example.
2. Differentiate depth-first search and breadth-first search traversal of a graph with suitable
examples.
3. Explain with algorithm, How DFS be performed on a undirected graph.
Click Here for Data Structures full study material.
4. Show the algorithm for finding connected components of an undirected graph using DFS,
and derive the time complexity of the algorithm.
5. Discuss an algorithm for Breadth first Search on a graph.
6. Discuss any two applications of Graph with example.
7. Explain the depth first approach of finding articulation points in a connected graph with
necessary algorithm.
8. Write short notes on Bi-connectivity.
UNIT-V
PART-A
1. Define sorting
Sorting arranges the numerical and alphabetical data present in a list in a specific order
or sequence. There are a number of sorting techniques available. The algorithms can be
chosen based on the following factors
– Size of the data structure
– Algorithm efficiency
– Programmer’s knowledge of the technique.
www.BrainKart.com
Click Here for Data Structures full study material.
www.BrainKart.com
Click Here for Data Structures full study material.
Disadvantages
x Efficiency of O(n ) is not well suited for large sized lists
x It requires large number of elements to be shifted
11. Define searching
Searching refers to determining whether an element is present in a given list of elements
or not. If the element is present, the search is considered as successful, otherwise it is
considered as an unsuccessful search. The choice of a searching technique is based on
the following factors
a. Order of elements in the list i.e., random or sorted
b. Size of the list
www.BrainKart.com
Click Here for Data Structures full study material.
www.BrainKart.com
Click Here for Data Structures full study material.
www.BrainKart.com
Click Here for Data Structures full study material.
20. Using binary search, search the number 26 from the list of numbers and give the
steps. 10,7,17,26,32,92
www.BrainKart.com