Poriyaan_CS3301 Data Structure-2-Mark-Question&Answer.bin
Poriyaan_CS3301 Data Structure-2-Mark-Question&Answer.bin
in/
UNIT-I
PART-A
.in
data types.
Eg. Array, stack queue, & tree.
an
3. What are Primary Data Structures?
Integers
Floating-point numbers.
iya
Character Constants
Arrays
Structures
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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).
9. List the operation of set ADT?
Union and Find are the two operations on set ADT
.in
Pointer: Pointer is a variable, which stores the address of another variable.
Using pointers, memory can be allocated dynamically.
Cursor: Cursor is a temporary memory space. Memory allocated is static.
an
13. What is an ordered list
An ordered list is a linear list which is been ordered by some key.
iya
Eg. An alphabetized list of students in a class, a list of exam scores in decreasing order.
Operations such as insertion and deletion Insertion and deletions are easier and
are ineffective since the memory locations needsonly one pointer assignment.
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
d. Nodes of a linked list cannot be accessed directly. To access a particular node accessing
should start only from the beginning.
e. To store a single data, along with data, memory must be allocated for a pointer also, which
wastes memory.
16. Write the steps required to evaluate the postfix expression.
Repeatedly read characters from postfix expression
If the character read is an operand, push the value associated with it into the stack
If it is an operator, pop the top two values from stack, apply the operator to them
and push the result back onto the stack.
.in
18. Define Doubly Linked List.
an
A doubly linked list is a list structure in which each node contains two pointer fields
along with a data field namely,
BLINK – Points to the previous node in the list
FLINK – Points to the successive node in the list
iya
or
PART-B
p
4. What is a linked list? Describe the suitable routine segments for any four operations.
5. Examine the algorithms to implement the doubly linked list and perform all the
operations on the created list.
6. Identify the array implementation of list and show all its operation.
7. Discuss the creation of a doubly linked list and appending the list.Give relevant coding in
C
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).
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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.
.in
19. Develop a C program to split a linked list into sub lists containing odd and even ordered
elements in them respectively.
UNIT- 2
an
PART-A
iya
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.
or
pointer exceeds maximum size during insertion. This can be rectified if we logically consider the
queue to be circular.
w.
In circular queue, once the rear pointer reaches the maximum size, the next location I the first
one (index 0), provided the first location is vacant. The specific location is calculated by mod
(%) operator.
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
5. Define Dequeue.
A dequeue is an ordered list in which additions and deletions may be carried out at either end.
7. 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
8. Define Modularization?
Modularization is the concept of isolating the complex implementation into set of
independent and easily identifiable units, to make the program easily understandable and
modifiable.
.in
9. What are the error conditions that could occur in stack implementation? How could they
be rectified?
an
Overflow
Underflow
To avoid overflow, the stack should be checked whether it is full or not before every push
iya
operation.
To avoid underflow, the stack should be checked for emptiness before every
pop operation.
or
times. But, conversion of Infix to Postfix or Prefix with use of stack, help to set precedence
based on order of arrangement in a single scanning
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
15. 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.
16. 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.
18. What are the two types of priority queues? Briefly explain?
Two types of priority queues are,
.in
i) Ascending priority queue – In this queue, the items can be inserted arbitrarily
and only the smallest item will be removed.
an
ii) Descending priority queue- This allows insertion of items arbitrarily, and only
the maximum element from queue will be removed first.
20. What are the limitations in priority queue? How it could be rectified?
p
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
w.
when each element is deleted. We can also maintain priority queue as an array of ordered
elements, to avoid risk in searching.
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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.
.in
15. Prepare an algorithm to perform the operations in a double ended queue.Develop a C
program for linked list implementation of stack.
an
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.
iya
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
or
PART-A
1. Define Tree.
p
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
w.
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
.in
6. Define nonterminal nodes in a tree
All intermediate nodes that traverse the given tree from its root node to the terminal
nodes are referred as terminal nodes.
an
7.efine a Binary Tree.
A Binary Tree is a tree,which has nodes either empty or not more than two child
iya
nodes,each of which may be a leaf node.
8.Define a full binary tree.
A full binary tree,is a tree in which all the leaves are on the same level and every non-leaf
or
A complete binary tree is a tree in which every non-leaf node has exactly two children
w.
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
Processing consumes excess of time.
Slow data movements up and down the array.
.in
Traverse the left subtree
Traverse the right subtree.
Ex : +AB
an
18.What are the tasks performed during inorder traversal?
Traverse the left subtree
Process the root node
iya
Traverse the right subtree.
Ex : A+B
or
Ex : AB+
20. Give the pre & postfix form of the expression (a + ((b*(c-e))/f).
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
The value in any left subtree is less than the value of its parent node.
The value in any right subtree is greater than the value of its parent node.
22.What do u mean by General trees?
General Tree is a tree with nodes having any number of children.
.in
An empty tree is height balanced. If T is a non-empty binary tree with TL and TR as
Its left and right subtrees, then T is height balanced if
1. TL and TR are height balanced.
2. | hL - hR | ≤ 1.
an
Where hl and hr are the height of TL and TR respectively.
iya
26.What are the drawbacks of AVL trees?
The drawbacks of AVL trees are
Frequent rotations
The need to maintain balances for the tree’ s nodes
or
assigned to its nodes, one key per node, provided the following two conditions
are met
The tree’s shape requirement-The binary tree is essentially complete, that is all
ww
the leaves are full except possibly the last level, where only some rightmost leaves
will be missing.
The parental dominance requirement-The key at each node is greater that or equal
to the keys of its children
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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
.in
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.
an
31.What are the two alternatives that are used to construct a heap?
The two alternatives to construct a heap are
iya
Bottom-up heap construction
Top-down heap construction
or
k I ; v H[k] heap false while not heap and 2*k n do j 2*k if j < n
if H[j] < H[j+1] j j+1
if v H[j]
heap true
else H[k] H[j]; k j
H[k] v
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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.
.in
35.What is a min-heap?
A min-heap is a mirror image of the heap structure. It is a complete binary tree in which
an
every element is less than or equal to its children. So the root of the min-heap contains the
smallest element.A B-tree of order m in an m-way search tree that is either empty or is of height
≥1 and
iya
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.
or
A Binary Heap is a complete binary tree in which the key value of any node must be
ww
lesser than its children is called min heap. If the key value of any node is greater than its children
is called max heap.Binary heap is also called as partially ordered tree.
For any element in the array position ‘i’, the left child is at the position ‘2i’, the right
child is at the position ‘2i+1’ and parent is at the position ‘i/2’.
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
.in
PART-B
1. Write an algorithm for preorder, inorder and postorder traversal of a binary tree.
an
2. Explain the following operations on a binary search tree with suitable
algorithms
a. Find a node
iya
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.
or
5. Discuss in detail the various methods in which a binary tree can be represented. Discuss
theadvantage and disadvantage of each method.
p
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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.
.in
directed graph.It is also called as digraph.
4.Define a cycle in a graph.
an
A cycle is a path containing atleast thee vertices such that the starting and the ending vertices
are the same.
5.Define a weakly connected graph.
iya
A directed graph is said to be a weakly connected graph if any vertex doesnt have a directed
path to any other vertices.
or
value.The weight of an edge is a positive value that may be representing the distance between the
vertices or the weights of the edges along the path.
w.
2
5 11
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
.in
12. Define In degree of a graph.
In a directed graph, for any node v, the number of incoming edges to vare called In degree of a
an
node v. Ex : In degree of c =1
The path in a graph is the route taken to reach the terminal node from a starting node.
The path from ato eare
P1 = ((a,b),(b,e))
ww
P2 = ((a,c),(c,d),(d,e))
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
18. Define minimum cost spanning tree?
A spanning tree of a connected graph G, is a tree consisting of edges and all the vertices of
G.
In minimum spanning tree T, for a given graph G, the total weights of the edges of the
spanning tree must be minimum compared to all other spanning trees generated from G.
-Prim’s and Kruskal is the algorithm for finding Minimum Cost Spanning Tree.
21. What is the use of Kruskal’s algorithm and who discovered it?
.in
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.
an
22. What is the use of Dijksra’s algorithm?
Dijkstra’s algorithm is used to solve the single-source shortest-paths problem: for a
iya
given vertex called the source in a weighted connected graph, find the shortest path to all
its other vertices. The single-source shortest-paths problem asks for a family of paths, each
leading from the source to a different vertex in the graph, though some paths may have edges in
common.
or
23. Prove that the maximum number of edges that a graph with n Vertices is
p
n*(n-1)/2.
Choose a vertex and draw edges from this vertex to the remaining n-1 vertices. Then, from
w.
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
ww
(n-1)+(n-2)+(n-3)+…+1 =n*(n-1)/2.
24. Define connected and strongly connected graph.
Two Vertices u and v are said to be connected if there exists a path from u to v in the graph. A
directed graph is said to be connected if every pair of vertices in the graph is connected.
A directed graph is said to be strongly connected if for every pair of distinct vertices v i and vj,
there exists two disjoint paths, one from vi to vj and the other from vj to vi.
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.
4. Show the algorithm for finding connected components of an undirected graph using
DFS, and derive the time complexity of the algorithm.
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
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
.in
chosen based on the following factors
– Size of the data structure
– Algorithm efficiency
an
– Programmer’s knowledge of the technique.
Mention the types of sorting
iya
2. x Internal sorting
x External sorting
or
memory of a computer. This is possible whenever the data to be sorted is small enough
to all be held in the main memory.
w.
External sorting is a term for a class of sorting algorithms that can handle massive
amounts of data. External sorting is required when the data being sorted do not fit into the
ww
main memory of a computing device (usually RAM) and instead they must reside in the
slower external memory (usually a hard drive)
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
b. Pass 2 : A[3] is compared with both A[1] and A[2] and inserted at an appropriate
place. This makes A[1], A[2],A[3] as a sorted sub array.
c. Pass n-1 : A[n] is compared with each element in the sub array
A[1],A[2],……A[n-1] and inserted at an appropriate position.
.in
the right.
7. What is meant by shell sort?
an
Shell sort, also known as Shell sort or Shell's method, is an in-place comparison sort. It
can either be seen as a generalization of sorting by exchange (bubble sort) or sorting
iya
by insertion (insertion sort).[1] The method starts by sorting elements far apart from
each other and progressively reducing the gap between them. Starting with far apart
elements can move some out-of-place elements into position faster than a simple
or
nearest neighbor exchange. Donald Shell published the first version of this sort in
1959. The running time of Shell sort is heavily dependent on the gap sequence it uses
p
w.
ww
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
.in
Radix Sort is a clever and intuitive little sorting algorithm. Radix sort is a non-
comparative integer sorting algorithm that sorts data with integer keys by grouping
keys by the individual digits which share the same significant position and value. Radix
an
Sort puts the elements in order by comparing the digits of the numbers.
Disadvantages
w.
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
.in
the array. If the key match, then a matching element has been found and its index, or
position, is returned.
Otherwise, if the search key is less than the middle element, then the algorithm repeats
an
its action on the sub-array to the left of the middle element or, if the search key is greater,
on the sub-array to the right.
iya
15. Define hashing function
A hashing function is a key-to-transformation, which acts upon a given key to compute
the relative position of the key in an array.
or
collisions with linked lists. In this hashing system, if a collision occurs, alternative cells
are tired until an empty cell is found.
There are three strategies in open addressing:
x Linear probing
x Quadratic probing
x Double hashing
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
17. What are the collision resolution methods?
The following are the collision resolution methods
x Separate chaining
x Open addressing
x Multiple hashing
.in
1.Compilers can use hash table to keep track of declared variable in source code.
2.A hash table is useful for any graph theory problem where nodes haver real
names instead of numbers
an
3.A third use of hash table is in program that play games.
4.On line spell checkers
iya
20, Explain Hashing .
Hashing is a technique used to identify the location of an identifier ‘x’ in the memory by
some arithmetic functions like f(x), which gives address of ‘x’ in the table.
or
table.
w.
2.Square method
3.Folding method
https://www.poriyaan.in/paper/data-structure-75/
www.poriyaan.in https://cse.poriyaan.in/
PART-B
1. Describe about selection sort with suitable example.
2. Examine the algorithm for Insertion sort and sort the following array: 77, 33,
44, 11, 88, 22, 66, 55
3. List the different types of hashing techniques? Explain them in detail with
example.
4. 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.
5. Write a C program to search a number with the given set of numbers using
binary search.
6. Interpret an algorithm to sort a set of ‘N’ numbers using bubble sort and
demonstrate the sorting steps for the following set of numbers:
88,11,22,44,66,99,32,67,54,10.
7. Discuss the various open addressing techniques in hashing with an example.
.in
8. Sort the given integers and Show the intermediate results using
shellsort:35,12,14,9,15,45,32,95,40,5.
9. Write an algorithm to sort an integer array using shell sort.
an
10. Illustrate with example the open addressing and chaining methods of techniques
collision resolution techniques in hashing.
iya
11. Compare working of binary search and linear search technique with example.
12. Analyze extendible hashing in brief.
13. Explain in detail about separate chaining.
or
16. Mention the different Sorting methods and Explain about method in detailed
w.
Manner.
17. Sort the sequence 96, 31, 27,42,76,61,10,4 using shell sort and radix sort and
ww
https://www.poriyaan.in/paper/data-structure-75/
Civil
CSE
Home Mech
e
EEE
CSE –2nd sem Reg 2021 ECE
Physics
Basic for Engineering
Electrical and Data Structure
Problem Solving and Science Engineering
Electronics
Python Programming Object Oriented
Programming in C
Programming
Elective-Management
Professional Elective II
Professional Elective IV