DSA Question Bank

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Sri Sai Vidya Vikas Shikshana Samithi ®

SAI VIDYA INSTITUTE OF TECHNOLOGY


(Approved by AICTE, New Delhi, Affiliated to VTU, Recognized by Govt. of Karnataka)
NBA Accredited (ECE, CSE, ISE, Mechanical, Civil), NAAC ‘A’ Grade
RAJANUKUNTE, BANGALORE 560 064, KARNATAKA
Phone: 080-28468191/96/97/98 * E-mail: [email protected] * URL www.saividya.ac.in

DEPARTMENT OF CSE
QUESTION BANK
SUBJECT TITLE Data Structures and Applications
SUBJECT TYPE Core
SUBJECT CODE BCS304
ACADEMIC YEAR 2023-24 (ODD SEMESTER) BATCH 2022-2026
SCHEME NEP scheme (Effective from the academic year 2023)
SEMESTER III
FACULTY NAME and Yashaswini D M
DESIGNATION Assistant Professor

Module -1
Q.
Questions BCL Cos
No.
1 What do you mean by Data Structure? Give the classification of Data Structures. L1 CO1

2 Define structure and union with suitable examples. L1 CO1

3 What is the difference between int *a and int a[5] and int *[5]? L2 CO1

Develop a structure to represent planets in the solar system. Each planet has
fields for the planet's name, its distance from the sun in miles and the number of
4 L3 CO1
moons it has. Write a program to read data for each planet and store. Also print
the planet that has highest number of moons.

5 Define a pointer. Write a C function to swap two numbers using pointers. L2 CO1

Differentiate between linear and non – linear data structures. Explain how a
6 L1 CO1
structure can be represented in C.

Define Arrays. Explain different types of arrays. How a one-dimensional array


7 L1 CO2
can be initialized? Explain with example
CO2
What are the various operations performed on arrays? Explain with algorithms?
8 L1
Write a C program to demonstrate basic array operations

Page | 1
9 L1 CO1
What is a sparse matrix? Briefly explain it with an example.

Write a C program with an appropriate structure definition and variable


declaration to store information about an employee using nested structures.
10 L3 CO1
Consider the following fields Ename, Empid, DoB (Day, Month, Year) and
salary (Basic, DA, HRA).

Consider 2 polynomials A(x)=2x10+1 and B(x)=x4+10x3+3x2+1, show


11 diagrammatically how these two polynomials can be stored in a single one- L2 CO1
dimensional array. Also give its C representation.

What are polynomials? Brief it with an example. Write a C program to add two
12 L2 CO1
polynomials.

13 Explain String function with an example. L2 CO1

Write a program in C to read a sparse matrix of integer values and search this
14 L3 CO1
matrix for an element specified by the user.

How would you represent two sparse polynomials using array of structure and
15 also write a function to add that and store polynomial the result in the same L2 CO1
array?

Define stack and List and implement basic operations in stack using C
16 (push, pop, isempty, isfull). Implement reversing a string using stack (array L1 CO2

implementation) in C.

17 Write a C program to implement multiple stacks using single array L1 CO2

18 Write short notes on Applications of stack L2 CO2

Write an algorithm to evaluate postfix expression. Trace the same


19 algorithm with stack contents for the following expression L3 CO2

A B C + * C B A - + * with A=1, B=2, C=3.

Convert each of the following expression to its postfix forms

a) ( A + B ) * C – D $ E * F
20 b) A - B / C * D $ E L3 CO2

c) ( A + B ) * ( C + D – E ) * F
d) ( ( ( A + ( B – C ) * D ) ^ E ) + F )
e) ( a + b ) * d + e / ( f + a * d ) + c

Page | 2
f) ( ( a / ( b - c + d ) ) * ( e - a ) * c )
g) a / b – c + d * e – a * c
What is recursion? Give two conditions to be followed for successive working
21 of recursive program. Write a 'c' recursive program to solve tower of Hanoi L2 CO2

problem.

Write a recursive function for computing nth Fibonacci term of a Fibonacci


22 L2 CO2
sequence. Hence give the trace of stack contents for n=4.

Determine what the following recursive C function computes

int func(int n)
{
if(n==0)
23 L3 CO2
return 0;
return (n+func(n-1));
}
Write an iterative function to accomplish the same.

24 Write a recursive function to find the GCD of two integers. L2 CO2

Convert the infix expression to postfix expression and evaluate the same.
25 L3 CO2
a / b – c + d * e – a * c for a=6, b=3, c=1, d=2, e=4.
Module -2

Q. RBC
Questions Cos
No. L

What is circular queue? What ate the advantages of Circular queue over
1 L2 CO2
simple queue.

What is a linear queue? What are the applications of linear queue?


2 Implement/Write a C program to simulate the 1) insert 2) delete 3) display L2 CO2

operations.

3 Explain priority queue. Explain the working of simple queue. L1 CO2

Explain how would you implement a circular queue using dynamically allocated
4 L1 CO2
arrays.
Assume a list exists. Read two numbers M and N from the list and swap them.
5 L1 CO3
Write a function to reverse a singly linked list.

Page | 3
Write a function to print an ordered list. (The list should sort and as and when
6 L1 CO3
the elements are entered) . Write a function to concatenate two lists.
Write a function to display nodes of a DLL in reverse order. Write a function to
7 L2 CO3
delete all nodes in SLL and DLL.
Give differences between SLL and DLL. Explain in detail the merits and
8 L1 CO3
demerits of linked lists
Distinguish arrays and linked lists Explain advantages of circular lists with
9 L1 CO3
respect to other lists.
10 What is the use of header node in a list. Explain with examples. L1 CO3
11 Write all four functions to implement circular DLL using header. CO3
12 Demonstrate queue and stack using singly linked list L2 CO3
Explain how a chain can be used to implement a queue. Write the functions to CO3
13 L2
insert and delete elements from such queue.
Write functions for the following
CO3
a. To find length of the list
14 b. To display odd and even numbers in the list L2
c. To add odd & even numbers in the list
d. To search a given node in the list
Create SLL of integers and write C functions to perform the following
a. Create a node list with data 10,20 and 30
15 b. Insert a node with value 15 in between 10 and 20 L2 CO3
c. Delete the node whose data is 20
d. Display the resulting SLL
Module 3
Q. Bloom’s
Questions Cos
No. LL
Describe DLL with advantages and disadvantages. Write C function to CO3
1 delete a node from DLL, ptr is a pointer which points to the node to be L3
deleted. Assume that there are nodes on either side of the node to be
deleted.
2 How do you insert a node at the beginning of a doubly linked list? L1 CO3
3 How do you insert a node at the end of a doubly linked list? L1 CO3
4 Write a function to reverse a doubly linked list. L2 CO3
Define the following: CO4
i) Skewed binary tree ii) Complete BT iii) Strictly binary
5 tree L1
iv) Binary Search Tree v) Depth of a tree vi) Sibling vii)
Degree viii) Internal Node ix) Ancestors x) Leaf Node
6 In brief describe any five applications of tree. L1 CO4

Page | 4
What are the different ways of representing a Binary tree? Explain with CO4
7 L2
an example. Give the advantages and disadvantages of each?
With an example, discuss the procedure to calculate the array size
9 requirement, index position of left and right subtree nodes in a binary tree L1 CO4
representation using an array.
10 Give the structure declaration of a node in a binary tree. L2 CO4
11 Write a C function to display the elements of BST in sorted order. L1 CO4
Write C functions for the following tree traversals:
12 L1 CO4
i) Inorder ii) Preorder iii) Postorder
Construct a binary tree from the given preorder and inorder sequence:
13 Preorder: A B D G C E H I F L3 CO4
Inorder: D G B A H E I C F
Construct a binary tree from the given preorder and inorder sequence:
14 Inorder: 4-8-2-5-1-6-3-7 L3 CO4
Postorder: 8-4-5-2-6-7-3-1
L
15 Create a BST of N Integers: 6, 9, 5, 2, 8, 15, 24, 14, 7, 8, 5, 2 CO4
3
Write the rules and construct an Expression tree for the expression L
16 CO4
i) A / B + C * D + E ii) a + b * c / f ^ g – h 3
17 Write a C function to achieve Iterative Inorder Tree Traversal. L3 CO4
Find the Inorder, Preorder and Postorder traversal for the following:

18 L1 CO4

19 With an example describe Binary Tree Level order traversal. Write the C L2 CO4
function to perform Binary Tree Level order traversal.
Write the C function to: i) Copy a binary tree to another binary tree.
20 ii) Check the equality of two binary trees.
iii) Count number of leaf node in a binary tree
iv) Find the largest element in a BST
Module -4
Bloom’s
Q. No. Questions Cos
LL
1 Construct BST for the following: 22, 28, 20, 25, 22, 15, 18, 10, 14 L3 CO4

Page | 5
Write recursive functions for the following operations on BST:
2 L1 CO4
i) Insert_key() ii) Delete_key() iii) Search_key()
3 Design a C program to create a Binary Search Tree of N Integers. L1 CO4
4 State the rules to delete a node in a Binary Search Tree. L1 CO4

5 Define a threaded binary tree. What are the advantages of threaded binary
tree over binary tree?
6 Define graph. Write the difference between graph and trees. Show the L1 CO4
adjacency matrix and adjacency list representation for the given graph.

7 Define a graph. For the given graph show the adjacency matrix and L3 CO4
adjacency list representation of the graph

Obtain DFS and BFS traversals for the given graph.

8 L2 CO4

9. Write a C function to implement DFS and BFS traversal. L3 CO4


Explain the following terminologies with respect to a graph? L2 CO4
• Degree of a node * Weighted graph * Adjacency matrix
10
• Connected graph * Complete graph * Directed Graph
• Subgraph * Multigraph
11 What is Spanning tree of a graph? Explain with an example how a L2 CO4
spanning tree is constructed using DFS traversal.
12 What are biconnected components? How can traversal algorithm be used L3 CO4
to find biconnected components of a graph?
13 Write a C function for insertion sort. Sort the following list using L3 CO4
insertion sort: 50, 30, 10, 70, 40, 20, 60
14 Apply radix sort for the following integers and explain every step: L3 CO4
348, 143, 361, 423, 538, 128, 321, 543, 366.

Page | 6
Module 5
Bloom’s
Q. No. Questions Cos
LL
1 What is hashing? What are the key components of hashing? How does it L2 CO5
improve access time of data?
2 What are the requirements that a good hashing function should satisfy? L3 CO5
Explain.
3 List the different types of hashing functions. Briefly explain each of them. L2 CO5
4 Elaborate the collision resolving by chaining method. L2 CO5
5 Describe static and dynamic hashing. L2 CO5
6 The following keys 10, 16, 11, 1, 3, 4, 23, and 15 are inserted into an L2 CO5
empty hash table of length of 10. Using Open addressing with hash
function h(k) = k mod 10 and linear probing. What is the resultant hash
table? Explain linear probing.
7 What is a priority queue? L2 CO5
8 How can a priority queue be implemented? L2 CO5
9 Describe an application where a priority queue is useful L2 CO5
10 How would you efficiently implement a priority queue with the ability to L2 CO5
decrease the priority of an element?
11 What is an Optimal Binary Search Tree (OBST)? L2 CO5
12 Explain the concept of "search cost" in the context of Optimal Binary L2 CO5
Search Trees.
13 How is the cost of an Optimal Binary Search Tree calculated? L2 CO5
14 What is the time complexity for constructing an Optimal Binary Search L2 CO5
Tree using dynamic programming?
15 How does the concept of "static" and "dynamic" search keys apply to L2 CO5
Optimal Binary Search Trees?

Course Coordinator Module Coordinator HOD

Page | 7

You might also like