Course Handout
Course Handout
Deemed to be University
BHUBANESWAR-751024
Course Handout
1. Course code : CS 2001
2. Course Title : Data Structure and Algorithms
3. LTP Structure :
L T P Total Credit
3 1 0 4 4
9. Course Outcome:
CO # Detail
CO1 Students will be able to understand the concepts of data structure, data type and
abstract data type (ADT) and compute the complexity of different algorithms.
CO2 Students will be able to understand, distinguish and implement Array and Linked list
data structure on different types of problems.
CO3 Students will be able to understand and implement different linear data structures such
as Stack and Queue to solve various problems.
CO4 Students will be able to understand and implement different non-linear data structures
such as Tree and Graph on various computing problems.
CO5 Students will be able to understand and apply standard algorithms for searching, sorting
and hashing.
CO6 Students will be able to effectively choose the data structure that efficiently models the
Information in a problem.
8. Course Contents
The course focuses on basic and essential topics in data structures and algorithms, including
arrays, linked lists, Stacks, Queues, Trees, sorting algorithms, searching algorithms and graphs.
Sr# Major Area Detailed Area
1 Introduction Structures and Unions, Pointers, Dynamic Memory Allocation,
Algorithm Specification, Space and Time Complexity
2 Arrays Arrays, Abstract Data Type, Dynamically Allocated Arrays,
Polynomials, Two-dimensional Array, Address Calculation, Matrix
Addition and Multiplication, Sparse Matrix, Upper & Lower
Triangular Matrix, Tridiagonal Matrix
3 Linked List Singly Linked Lists and Chains, Representing Chains in C,
Polynomials, Sparse Matrix, Doubly Linked Lists, Circular &
Header Linked lists
4 Stacks and Queues Stacks, Stacks using Dynamic Arrays and Linked List, Queues,
Queue using Dynamic Arrays and Linked List, Circular Queues
using Dynamic Arrays and Linked List, Evaluation of Expressions,
Priority Queue, Dequeue
5 Trees Introduction, Binary Trees, Binary Tree Traversals, Threaded
Binary Trees, Binary Search Trees, AVL Trees, m-way Search
Trees, B-Trees, Introduction to B+-Trees, Tree Operation, Forests
6 Graphs Graph ADT, Graph Operation – DFS, BFS
7 Sorting Insertion Sort, Quick Sort, Merge Sort, Heap Sort, Bubble Sort,
Selection Sort, Radix Sort
8 Searching Linear Search, Binary Search, Hashing – Hash Function, Collision
Resolution Techniques
9. Text Book:
T1. Fundamentals of Data Structures in C, 2nd Edition, Horowitz, Sahani Anderson-Freed, Universities
Press. Pearson, 1st Edition
RB5. Data Structures and Algorithm Analysis in C, Mark Allen Weiss, Pearson Education,
2nd Edition.
11. Reference Site:
12. Pre-requisites:
Programming in C (CS-1001)
Mathematics for Computer Science
13. The day-wise course coverage depicts the provisional date of covering individual topics of the
DS&A subject in the academic session of autumn 2019-2020.
Lecture Unit Topics
No. Lesson #
Arithmetic Expression
Conversion 13/8/19
Class Work
Introduction to Queues
Queues Application
14/8/19
Queues Representation – Arrays
Assignment -2 submission
Queues Representation – Linked
List
16/8/19
Queues ADT
Class Work
Linear Queue Drawback
Circular Queues 19/8/19
Deques
Priority Queue 20/8/19
Class Work
Class Test - Quiz 1
21/8/19
Doubt clearing
26-37 Trees Introduction to Trees
Trees Terminology 4/9/19
Class Work
Tress Application
Binary Tree – Full, Complete and
Extended Binary Trees 6/9/19
Expression Trees
Class Work
Representation of Binary Tree –
Linked and Array Representation 10/9/19
Binary Tree ADT
Arithmetic Expression
Conversion 11/9/19
Class Work
Binary Tree Traversal Concept
and Algorithm – In-Order, Pre-
Order and Post-Order & Level- 13/9/19
Order
Binary Tree Construction with
Lecture Unit Topics
No. Lesson #
different traversal
Class Work on Binary Tree
Threaded Binary Tree – Single 16/9/19
and Double Threaded
Binary Search Tree
17/9/19
BST ADT – Search, insertion
BST ADT – Deletion,
18/9/19
Class Work
Balanced Binary Tree
AVL Tree 20/9/19
AVL Rotation Techniques, ADT
Multi-way Search Tree & ADT
23/9/19
B-Tree & ADT
B+ Tree Introduction
24/9/19
Forest
Tutorial Class
25/9/19
Assignment – 4 submission
38-40 Graphs Introduction to Graph
Graph Terminology 27/9/19
Graph Application
Graph Representation
30/9/19
Class Work
Graph Operation – DFS and BFS
Class Work 1/10/19
Class Discussion
Quiz – 2 4/10/19
Heap Sort
Radix Sort 16/10/19
Assignment – 5 submission
Class Discussion 18/10/19
44-47 Searching Linear Search
21/10/19
Binary Search
Hashing – Hash Function
22/10/19
Class Work
Hashing – Collision Resolution
Technique 23/10/19
Class Work
Tutorial Class 25/10/19
48-52 Mini Project Mini Project Evaluation 28/10/19,
29/10/19,
30/10/19,
1/11/19
53-62 Discussion Doubt clearing 4/11/19,
5/11/19,
6/11/19,
8/11/19,
11/11/19,
13/11/19,
15/11/19,
18/11/19,
19/11/19
14. Assessment Components:
Sr # Assessment Time Weightage/ Date Course Lecture No. Mode
Component Marks
From To
1 Mid-Semester 1.5 Hrs 20 3rd Sept – 1 22 Closed Book
Examination 8th Sept
2 Activity based Through 30 Throughout NA NA Open Book,
Teaching and out semester Closed Book
Learning semester and
Presentation
3 End-Semester 3 Hrs 50 26th Nov – 1 49 Closed Book
Examination 12th Dec
Mid-semester question paper comprises of 5 questions and students have to answer any four questions including
question no 1, which is compulsory. Weightage for each question is 5. There will be 5 parts in question no 1.
End-semester question paper comprises of 8 questions and students have to answer any six questions including
question no 1, which is compulsory. Weightage for 1 st question is 10 and 8 for others. There will be 10 parts in
question no 1.
15. Assessment plan for active learning activities:
Considering the guidelines circulated and after discussing with the faculty members, following activity
based teaching and learning is proposed:
Activity List
Component wise distributions of the activities are listed below.
Problem Solving Critical Thinking Quiz
15 10 5
Considering the guidelines circulated and after discussing with the faculty members, following
component wise description of each activity list is proposed:
15.1Problem solving (15 marks): Assignment
Assignments have to be solved in a group/individual and mentioned below for reference only. Faculties
are free to give their own assignments and evaluation is to be done by respective assigned subject teacher.
Subject teacher have to decide the number of groups and students for each group. Students are expected
to write the solution in the writing pad and submit the soft copy to the subject teacher.
Assignment-1 (Introduction)
Find the time complexity of the following code segment
Q.
for (i = 1; i <= n; i = i*2)
{
for (j = n; j >= 1; j = j/2) { some statement }
}
Q.
for (i = 1; i <= n; i = i*2)
{
for (j = n; j >= 1; j = j/2) { some statement }
}
Q.
for (i = 1; i <= n; i = i*2)
{
for (j = n; j >= 1; j = j/2) { some statement }
}
Write an recursive algorithm to print from 1 to n (where n > 1)
Write an recursive algorithm to find the kth smallest element of a set S
Write an recursive algorithm to sum the list of numbers
Find the time and space complexity of the following code segment
Q.
int Factorial (int n) {
if n == 0 then
return 0;
else
return n * Factorial(n – 1)
}
Q.
int Fib(int n)
{
if n <= 1 then
return 1;
else
return Fib(n-1) + Fib (n – 2)
}
Q.
int GCD(int x, int y)
{
if y == 0 then
return x
else if x >= y AND y > 0
return GCD (y, x % y)
else
return 0;
}
What are the operations can be performed on various data structure?
What are the advantages of using ADT?
Explain Top-Down and Bottom-Up approach in designing the algorithm
Explain little o and little omega (w) notation.
In how many ways can you categorize data structures? Explain each of them.
What do you understand by time–space trade-off?
Explain the criteria that you will keep in mind while choosing an appropriate algorithm to solve a
particular problem.
Discuss the significance and limitations of the Big O notation.
Design an algorithm whose worst case time complexity is O(m + n log n)
Design an algorithm whose worst case time complexity is O(m + n2 log m)
Design an algorithm whose worst case time complexity is O(m2+ n (log m)2)
Write best case, worst case and average case time complexity of following categories of
algorithm –
o Constant time
o Linear time
o Logarithmic time
o Polynomial time
o Exponential time
Assignment-2 (Arrays)
Write an algorithm to add the original sparse matrix with the transpose of the same matrix.
Write an algorithm to multiply two sparse matrices.
Design an efficient data structure to store data for lower and upper triangular matrix.
Design an algorithm to convert a lower triangular matrix to upper triangular matrix.
Design an efficient data structure to store data for tri-diagonal matrix.
Write an algorithm that takes as input the size of the array and the elements in the array and a
particular index and prints the element at that index.
Write down the algorithm to sort elements by their frequency.
Write down the algorithm to add two polynomials of single variable.
Write down the algorithm to multiply two polynomials of two variables.
A program P reads in 500 random integers in the range [0..100] presenting the scores of 500
students. It then prints the frequency of each score above 50. What would be the best way for P to
store the frequencies?
Write down the algorithm to delete all the vowels in a character array.
Write down the algorithm to print all the elements below the minor diagonal in a 2-D array.
Write an algorithm to find a triplet that sum to a given value
Given an array arr, write an algorithm to find the maximum j – i such that arr[j] > arr[i]
Write an algorithm to replace every element in the array with the next greatest element present in
the same array.
Assignment-3 (Linked List)
Design algorithm/develop pseudocode/write C code to add a given value K to each element in the
LIST.
Design algorithm/develop pseudocode/write C code to deletes the last node from the LIST.
Design algorithm/develop pseudocode/write C code to delete the 1st node from the list.
Design algorithm/develop pseudocode/write C code which interchanges the Kth and K+1st
elements
Design algorithm/develop pseudocode/write C code to swap nodes in a linked list without
swapping data.
Design algorithm/develop pseudocode/write C code to reverse the nodes in a linked list.
Design algorithm/develop pseudocode/write C code to create a linked list from a given linked list.
The new linked list must contain every alternate element of the existing linked list.
Design algorithm/develop pseudocode/write C code to count the number of times a given key
occurs in a linked list
Let a linked list consists of n number of nodes, where each node consists of an unique number, a
priority number(in between 1 to 5), and pointer to next node Design the algorithm/develop
pseudocode/write C code to divide the nodes into different linked list where each linked consists
of nodes having same priority.
Design algorithm/develop pseudocode/write C code to delete n nodes after m nodes of a linked
list
Design algorithm/develop pseudocode/write C code to check if a singly linked list is palindrome
Design algorithm/develop pseudocode/write C code to search an element in a linked list, if found
delete that node and insert that node at beginning. Otherwise display an appropriate message.
Design algorithm/develop pseudocode/write C code to add, subtract and multiply 2 polynomials.
Design algorithm/develop pseudocode/write C code to delete last occurrence of an item from
linked list
Given a singly linked list with nodes L0 -> L1 -> … -> Ln-1 -> Ln. Design the algorithm/develop
pseudocode/write C code to rearrange the nodes in the list so that the new formed list is : L0 ->
Ln -> L1 -> Ln-1 -> L2 -> Ln-2 …
Assignment-4 (Stack & Queues)
Write an algorithm to convert an infix expression into it equivalent postfix expression. Explain
the execution of algorithm using the following expression (A+B) * C – (D * E) î (F + G + (H *
M))
Write pseudo code to check whether a given postfix expression is correctly parenthesized
Evaluate the postfix expression: 5 3 2 * + 7 9 /4 * 2 / - 6 + 2 –
Write C functions for insertion, deletion, traversal operation for circular queues
Write C functions for insertion, deletion, traversal operation for input restricted deques
Write an algorithm to copy the data elements of one stack to other without changing the order and
without using any other data structure
Write C functions for insertion, deletion, traversal operation for priority queues
Write an algorithm to check for balanced parentheses (, ), {, }, [ and ] in an expression
Write recursive pseudo code or recursive function to display the string in reverse order.
Write an algorithm to convert postfix expression to infix expression.
Write an algorithm to convert prefix expression to infix expression.
We are given stack data structure, the task is to implement queue using only given stack data
structure.
We are given queue data structure, the task is to implement stack using only given queue data
structure.
Write an algorithm or c code segment for insertion, deletion, peek and traversal of priority queue
using dynamic arrays
Write an algorithm or c code segment for Postfix to Infix conversion
Write an algorithm or c code segment for Prefix to Infix conversion
Write an algorithm or c code segment for Postfix to Prefix conversion
Write an algorithm or c code segment for Postfix to Prefix conversion
Write C functions for insertion, deletion, traversal operation for input restricted deques
Assignment-5 (Trees)
A binary tree has 9 nodes. The inorder and preorder traversal of T yields the following sequence
of node. Inorder: E, A, C, K, F, H, D,B,G and Preorder: F, A, E, K, C, D, H, G, B. Draw the tree
T
Suppose T is a binary tree. Write a recursive & non-recursive algorithm to find the number of leaf
nodes, number of nodes and depth in T. Depth of T is 1 more than the maximum depths of the
depths of the left and right subtrees of T.
Suppose T is a binary tree. Write a recursive & non-recursive algorithm to find the height of T.
Insert the following keys in the order to form the binary search tree J, R, D, G, T, E, M, H, P, A,
F, Q
Insert the following keys in the order to form the binary search tree 50, 33, 44, 22, 77, 35, 60, 40
Suppose a binary tree T is in memory. Write the pseudo code to delete all terminals or leaf nodes
in T
Write a C function to copy the binary tree T to T’
Suppose ROOTA points to a binary tree T1. Write the pseudo code which makes a copy T2 of the
tree T1 using ROOTB as pointer
Write algorithm to insert and delete the nodes in B tree.
Write a program to check whether the binary tree is a binary search tree
Write the non-recursive function for inorder traversal, preorder traversal, and postorder traversal
of a binary tree.
Write a function to display all the paths from root to leaf nodes in a binary tree.
Write a programme to insert a node into BST both in recursive and non-recursive manner.
Write a programme to display the nodes of a tree in level wise(first we need to display 0th level
node, then 1th level nodes and so on).
Write a program to check whether a binary tree is an AVL tree.
Assignment-6 (Graphs)
Write C code snippet (function) to
Represent the graph using Adjacency Matrix
Represent the graph using Adjacency List
Find if there is a path between pair of vertices in an undirected and directed graph
Find the number of isolated vertices in an undirected graph.
Check if a given undirected graph is a tree (an undirected graph is a tree is there is cycle and is
connected)
Find a mother vertex in a graph. Mother is a vertex v such that all other vertices in G can be
reached by a path from v. There can be more than one mother vertices in a graph. Need to output
anyone of them.
Detect a cycle in directed graph
Find the bridges in the undirected graph. An edge in an undirected connected graph is a bridge if
removing it disconnects the graph
Two/Three quizzes with easy, moderate and difficulty level will be conducted at the mid and end of
semester according to the standard of GATE. Sample quiz is shown for reference only. Faculties are free
to give their own questions in the quiz. Evaluation is to be done by respective assigned subject teacher.
Consider a linear array int array[3][2] = {{45,23},{333,21},{90,45}} in 16-bit OS and the base
address of the array is 1000 and is presented in memory as Row Major. What is the address of the
element located at the index [1][1] ___________________?
Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected,
undirected graph. The tree T formed by the tree arcs is a data structure for computing.
(A) the shortest path between every pair of vertices.
(B) the shortest path from W to every vertex in the graph.
(C) the shortest paths from W to only those nodes that are leaves of T.
(D) the longest path in the graph
16. Unit wise Activity List:
Protocol:
Students have to submit 5 out of 7 assignments.
Students have to submit the mini project.
Students have to appear at least 2 quizzes.
17. Course Materials: Course Material will be provided for all topics which can be used as reference. The
material consists of –
Lecture Notes Home Work
Class Work Supplementary Reading
18. Attendance: Every student is expected to be regular (in attendance) in all lecture classes, tutorials, labs,
tests, quizzes, seminars etc and in fulfilling all tasks assigned to him / her. Attendance will be recorded and
75% attendance is compulsory.
19. Makeup:
No make-up examination will be scheduled for the mid semester examination. However, official
permission to take a make-up examination will be given under exceptional circumstances such as
admission in a hospital due to illness / injury, calamity in the family at the time of examination.
A student who misses a mid-semester examination because of extenuating circumstances such as
admission in a hospital due to illness / injury, calamity in the family may apply in writing via an
application form with supporting document(s) and medical certificate to the Dean of the School for a
make-up examination.
Applications should be made within five working days after the missed examination.
20. Discussion of Mid Semester performance: Performance of the mid semester examination will be
discussed in the class room
21. Pre-end semester total marks: To be announced and discussed in the class.
22. Course Management System: SAP Portal - Is a software system designed to facilitate teachers in the
management (instructional content, assessment and documentation) of the courses for their students, both
teachers and students can monitor the system. Though usually considered as a tool and often used to
complement the face-to-face classroom.
23. Chamber consultation hour for doubts clarification: To be announced in the class.
24. Academic Dishonesty:
It may be noted that any kind of copying/plagiarism by any student and/or malpractice in examinations
is strictly prohibited.
In case of the violation of above the Institute will take appropriate and necessary action.
25. Notices: All notices regarding the course will be displayed on respective school notice board /school of
computer engineering/ SAP portal.