Computer
Data Structures and Algorithm Database System and Operating System
Sorting, searching, and graphs

Sorting, searching, and graphs

Types of Sorting

Internal Sorting

  1. Insertion Sort: sorting one element at a time, and inserting each element into its proper place.
  2. Selection Sort: finding smallest element in the list and swapping it with first element and second place for second smallest element.
  3. Bubble/Exchange Sort: by comparing and swapping adjacent elements in the list by swapping them if they are in the wrong order.
  4. Quick Sort: divide and conquer algorithm that works by selecting pivot element, and doing partition around the pivot and recursively sorting each sub list.
  5. Merge Sort: dividing list into two halves, and sorting each half and then merging the two sorted halves.
  6. Heap Sort: based on heap data structure which is a binary tree, where each node is greater than or equals to its child.
  7. Shell Sort: Based on insertion sort, and works by comparing elements that are further apart in the list first, and moving them closer.
Sorting AlgorithmTime ComplexitySpace ComplexityApplication
Insertion SortO(n^2)O(1)Small data set, partially sorted values
Selection SortO(n^2)O(1)Small data set, with duplicate values
Bubble/Exchange SortO(n^2)O(1)Small data set, Education
Quick SortO(n^2), θ(nlogn)O(logn)Large Dataset, randomly ordered
Merge SortO(nlogn)O(n)Large dataset, partially stored data
Heap SortO(nlogn)O(1)Efficient, data with duplicates
Shell SortO(nlogn^2)O(1)Efficient for data with small number of possible values.

External Sorting

Technique used to sort large amount of data the doesn’t fit in the memory entirely. Works by dividing the data into smaller pieces that can be sorted separately.

Example: External Merge Sort and Distribution Sort.

Heap sort as a priority queue

Big ‘O’ notation and Efficiency of sorting

Search technique

Sequential search

Binary search

Tree search

General search tree

Hashing

Hash function and hash tables

Collision resolution technique

Undirected and Directed Graphs

Representation of Graph

Transitive closure of graph

Warshall’s algorithm

Depth First Traversal and Breadth First Traversal of Graph

Topological sorting

Depth first topological sorting

Breadth first topological sorting

Minimum spanning trees

Prim’s algorithm

Kruskal’s algorithm

Round- Robin algorithm

Shortest-path algorithm

Greedy algorithm

Dijkstra’s Algorithm