Data Structure - CS3301 - Question Bank and Important 2 Marks Questions With Answer
Data Structure - CS3301 - Question Bank and Important 2 Marks Questions With Answer
Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics GE3451
I - HS3152 - MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester
4th Semester
- MA3151 MA3251 Computer Organization
1st Semester
2nd Semester
8th Semester
6th Semester
Question Bank
UNIT I LISTS 9
Abstract Data Types (ADTs) – List ADT – Array-based implementation – Linked list
implementation – Singly linked lists – Circularly linked lists – Doubly-linked lists – Applications
of lists – Polynomial ADT – Radix Sort – Multilists.
TEXT BOOKS:
1. Mark Allen Weiss, “Data Structures and Algorithm Analysis in C”, 2nd Edition, Pearson
Education,2005.
2. Kamthane, Introduction to Data Structures in C, 1st Edition, Pearson Education, 2007
REFERENCES:
1. Langsam, Augenstein and Tanenbaum, Data Structures Using C and C++, 2nd Edition, Pearson
Education, 2015.
2. Thomas H. Cormen, Charles E. Leiserson, Ronald L.Rivest, Clifford Stein, Introduction to
Algorithms", Fourth Edition, Mcgraw Hill/ MIT Press, 2022.
3. Alfred V. Aho, Jeffrey D. Ullman,John E. Hopcroft ,Data Structures and Algorithms, 1st edition,
Pearson, 2002.
4. Kruse, Data Structures and Program Design in C, 2nd Edition, Pearson Education, 2006.
UNIT I
doubly-linked lists 67
15 When doubly linked list can be represented as circular linked C311.1 BTL 1
list?
In a doubly linked list, all nodes are connected with
forward and backward links to the
next and previous nodes respectively. In order to implement
circular linked lists from
doubly linked lists, the first node’s previous field is connected to
the last node and the
last node’s next field is connected to the first node.
20 The polynomial equation can be represented with linked list C311.1 BTL 2
as follows:
Coefficient Exponent Next node link
struct polynomial
{
int coefficient;
int exponent;
struct polynomial *next;
};
22 What are the merits and demerits of array implementation of C311.1 BTL 1
lists?
Merits
Fast, random access of elements
Memory efficient – very less amount of memory is
required
Demerits
Insertion and deletion operations are very slow since the
elements should be
moved.
Redundant memory space – difficult to estimate the size of
array.
27 List out the different ways to implement the list? C311.1 BTL 1
1. Array Based Implementation
2. Linked list Implementation
i. Singly linked list
ii. Doubly linked list
iii. Cursor based linked list
28 Write the routine for insertion operation of singly linked list. C311.1 BTL 5
Void Insert (ElementType X, List L, Position P)
{Position TmpCell;
TmpCell=malloc(sizeof(struct Node));
if(TmpCell==NULL)
FatalError(“Out of space!!!”);
TmpCell->Element =X; TmpCell->Next=P->Next;
P->Next=TmpCell;
}
The header node is the very first node of the linked list. Sometimes a
dummy value such - 999 is stored in the data field of header node. This
node is useful for getting the starting address of the linked list.
44 What is static linked list? State any two applications of it. C311.1
➢ The linked list structure which can be represented using arrays is
called static linked list.
➢ It is easy to implement, hence for creation of small databases, it is
useful
.➢ The searching of any record is efficient, hence the applications in
which the record need to be searched quickly, the static linked list are
used.
PART-B
1 Explain the various operations of the list ADT with examples C311.1
BTL 2
2 Write the program for array implementation of lists C311.1 BTL 5
3 Write a C program for linked list implementation of list. C311.1 BTL 5
UNIT II
Stack ADT 78
Operations 79
Circular Queue 95
STACK QUEUE
22 Convert the infix (a+b)*(c+d)/f into postfix & prefix C311.2 BTL5
expression
Postfix :ab+cd+*f/
Prefix :/*+ab+cdf
A-B+C-D+
25 What are the postfix and prefix forms of the expression? C311.2 BTL1
A+B*(C-D)/(P-R)
Postfix form: ABCD-*PR-/+
Prefix form: +A/*B-CD-PR
27 Define priority queue with diagram and give the operations. C311.2 BTL1
Priority queue is a data structure that allows at least the
following two operations.
1. Insert-inserts an element at the end of the list called the rear.
2. DeleteMin-Finds, returns and removes the minimum element
in the priority Queue.
UNIT III
B-Tree 149
B+ Tree 154
5 List out the steps involved in deleting a node from a binary C311.3 BTL1
search tree.
1. t has no right hand child node t->r == z
2. t has a right hand child but its right hand child node has
no left sub tree
t->r->l == z
3.t has a right hand child node and the right hand child node
has a left hand child node t->r-
>l != z
7 What are the steps to convert a general tree into binary C311.3 BTL1
tree?
* use the root of the general tree as the root of the binary tree
* determine the first child of the root. This is the leftmost node
in the general tree at the next
level
* insert this node. The child reference of the parent node refers
to this node
* continue finding the first child of each parent node and insert it
below the parent node with the
child reference of the parent to this node.
* when no more first children exist in the path just used, move
back to the parent of the last node
entered and repeat the above process. In other words,
determine the first sibling of the last
node entered.
* complete the tree for all nodes. In order to locate where the
node fits you must search for the
first child at that level and then follow the sibling references to
a nil where the next sibling can
be inserted. The children of any sibling node can be inserted
by locating the parent and then
inserting the first child. Then the above process is repeated.
23 Define binary tree and give the binary tree node structure. C311.3 BTL1
24 What are the different ways of representing a Binary Tree? C311.3 BTL1
Linear Representation using Arrays.
Linked Representation using Pointers.
25 Give the pre & postfix form of the expression (a + ((b*(c- C311.3 BTL2
e))/f).
UNIT IV
6 Mention any two decision problems which are NP-Complete. C311.4 BTL2
NP is the class of decision problems for which a given proposed
solution for a given input can be checked quickly to see if it is really a
solution
23 What are the two traversal strategies used in traversing a graph? C311.4 BTL1
a. Breadth first search
b. Depth first search
24 What is a minimum spanning tree? C311.4 BTL1
A minimum spanning tree of an undirected graph G is a tree
formed from graph edges that connects all the vertices of G at the lowest
total cost.
26 What is the use of Kruskal’s algorithm and who discovered it? C311.4 BTL1
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.
27 What is the use of Dijksra’s algorithm? C311.4 BTL1
Dijkstra’s algorithm is used to solve the single-source shortest-
paths problem: for a 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.
28 Prove that the maximum number of edges that a graph with n C311.4 BTL5
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.
6 Write and explain the prim’s algorithm and depth first search C311.4 BTL5
algorithm.
7 For the graph given below, construct Prims algorithm C311.4 BTL5
2
4 1 2 1 7
8 4 5
3 5 1 4 6
1 2
6 7
UNIT V
4 How the insertion sort is done with the array? C311.5 BTL1
It sorts a list of elements by inserting each successive element in the
previously sorted
Sub list.
Consider an array to be sorted A[1],A[2],….A[n]
a. Pass 1: A[2] is compared with A[1] and placed them in sorted order.
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.
11 what is insertion sort? How many passes are required for the C311.5 BTL1
elements to be sorted ?
one of the simplest sorting algorithms is the insertion sort. Insertion
sort consist of N-1 passes . For pass P=1 through N-1 , insertion sort
ensures that the elements in positions 0 through P-1 are in sorted
order .It makes use of the fact that elements in position 0 through P-
1 are already known to be in sorted order .
16 Mention some methods for choosing the pivot element in quick C311.5 BTL2
sort?
1. Choosing first element
2. Generate random number
3. Median of three
17 What are the three cases that arise during the left to right scan C311.5 BTL1
in quick sort?
1. I and j cross each other
2. I and j do not cross each other
3. I and j points the same position
27 How does the bubble sort get its name? C311.5 BTL1
The bubble sort derives its name from the fact that the
smallest data item bubbles up to the top of the sorted array.
28 What is the main idea behind the selection sort? C311.5 BTL1
The main idea behind the selection sort is to find the smallest entry
among in a(j),a(j+1),… ..... a(n) and then interchange it with a(j).
This process is then repeated for each value of j.
29 Is the heap sort always better than the quick sort? C311.5 BTL4
No, the heap sort does not perform better than the quick sort.
Only when array is nearly sorted to begin with the heap sort
algorithm gains an advantage. In such a case, the quick deteriorates
to its worst performance of O (n2).
5 Write a C program to sort the elements using bubble sort, C311.5 BTL5
insertion sort and radix sort.
4th Semester
2nd Semester
Deep Learning -
AD3501
Embedded Systems
Data and Information Human Values and
and IoT - CS3691
5th Semester
7th Semester
8th Semester
Open Elective-1
Distributed Computing Open Elective 2
- CS3551 Project Work /
Elective-3
Open Elective 3 Intership
Big Data Analytics - Elective-4
CCS334 Open Elective 4
Elective-5
Elective 1 Management Elective
Elective-6
Elective 2
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering
Click on Subject/Paper under Semester to enter.
Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics GE3451
I - HS3152 - MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester
4th Semester
- MA3151 MA3251 Computer Organization
1st Semester
2nd Semester
8th Semester
6th Semester
4th Semester
- MA3151 MA3251 Computer Organization
1st Semester
2nd Semester
Computer Networks -
CS3591
Object Oriented
Full Stack Web Software Engineering - Human Values and
5th Semester
8th Semester
6th Semester
Elective 1 Elective-5
Management Elective
Elective-6
Elective 2
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering