2.1 ADSA Lecture-Unit-II-Ch1
2.1 ADSA Lecture-Unit-II-Ch1
UNIT-I (15h)
Introduction to Basic Data Structures: Importance and need of good data structures and algorithms, Introduction
to linear and non-linear data structure and its importance, Algorithms Complexity and Analysis. [3]
Linear and Non –Linear Data Structures : Arrays , Link Lists, Queues , Trees and related algorithms [6]
Advanced Data Structures: AVL Trees (Insertion , Deletion , Searching), Red-Black Trees, B-trees, B+trees,
Heaps. Data structure for disjoint sets, Augmented data structures. [6]
UNIT-II (15h)
Searching and Sorting : Internal and External Sorting algorithms: Linear Search, Binary Search, Bubble Sort,
Selection Sort, Insertion Sort, Shell Sort, Quick Sort, Heap Sort, Merge Sort, Counting Sort, Radix Sort and
analysis of their complexities and Hashing
[4]
Graphs & Algorithms: Representation, Type of Graphs, Depth- and breadth-first traversals, Planar graphs,
isomorphism, graph coloring, covering and partition, Minimum Spanning Tree: Prim’s and Kruskal’s
algorithms. [6]
String Matching Algorithms: Naïve String Matching, Suffix arrays, Suffix trees, Rabin-Karp, Knuth-Morris-
Pratt, Booyer-Moore algorithm [5]
UNIT-III (15h)
Approximation algorithms: Need of approximation algorithms: Introduction to P, NP, NP-Hard and NP-Complete Greedy
Approach, Dynamic Approach, Knapsack, Huffman Coding, TSP, All pair shortest path, Longest Common Subsequence
Problem, Matrix Chain Multiplication. [7]
Randomized algorithms: Introduction, type of randomized algorithms, Quick sort, min cut
[4]
Online Algorithms: Introduction, Online Paging Problem, k-server Problem. Data compression: Huffman’s coding,
BWT, LZW
[4]
Recommended Books:
1. Cormen, Leiserson, Rivest, Stein, “Introduction to Algorithms”, Prentice Hall of India, 3rd edition 2012.
2. Horowitz, Sahni and Rajasekaran, “Fundamental of Computer, Algorithms”, University Press (India),
2nd edition.
3. Aho, Haperoft and Ullman, “The Design and analysis of Computer Algorithms”, Pearson Education
India.
Sorting
Types Of Sorting
• Bubble sort
• Insertion sort
• Selection sort
• Merge sort
• Quick sort
• Heap sort
• Shell sort
• Cycle sort
• Count sort
• Radix Sort
Bubble Sort
• Exchange two adjacent elements if they are out of order. Repeat until array is sorted.
• Example:
Take an array of numbers " 5 1 4 2 8", and sort the array from lowest
number to greatest number using bubble sort. In each step, elements
written in bold are being compared. Three passes will be required;
Step-by-step example
Bubble Sort
BUBBLE(DATA, N)
Here DATA is an array with N elements. This algorithm sorts the elements in DATA.
1.Repeat steps 2 and 3 for K = 1 to N – 1
2.Set PTR = 1 [Initialize pass pointer PTR]
3.Repeat while PTR ≤ N – K [Executes pass]
a) If DATA[PTR] > DATA[PTR + 1], then
Interchange DATA[PTR] and DATA[PTR + 1]
[End of If structure]
b) Set PTR = PTR + 1
[End of inner loop]
[End of step 1 outer loop]
4.Exit
Insertion sort
Insertion sort is a simple sorting algorithm that works the way we sort
playing cards in our hands
Algorithm
Selection Sort
• Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place
comparison-based algorithm in which the list is divided into two parts, the
sorted part at the left end and the unsorted part at the right end. Initially, the
sorted part is empty and the unsorted part is the entire list.
• The smallest element is selected from the unsorted array and swapped with the
leftmost element, and that element becomes a part of the sorted array. This
process continues moving unsorted array boundary by one element to the right.
• This algorithm is not suitable for large data sets as its average and worst case
complexities are of Ο(n2), where n is the number of items.
Example
Algorithm
Books Recommended
References
Thank you