Unit 4 of MAKAUT C Programming (PPS-II) contains high-weightage topics including 2D matrix mathematics, null-terminated string handling without library functions, and full implementations of 6 major sorting algorithms.

In MAKAUT semester exams, sorting algorithm derivations, time complexities, stability analyses, and matrix multiplication implementations carry up to 35 marks across Groups B and C.

---

1. 2D Arrays & Row-Major Memory Formulas

A 2D array is stored in Row-Major Order in C memory (rows stored sequentially).

Row-Major Address Formula:

Address(A[i][j]) = Base Address + (i × C + j) × sizeof(datatype)

where C is the total number of columns in the matrix.

Matrix Multiplication C Program (O(N^3))

*Exam Context: Group C (15 Marks)*

c

---

2. String Manipulation Without Library Functions

In C, a string is a 1D char array terminated by null byte '\0'.

Custom strcpy and strcat Pointer Implementation

c

---

3. Masterclass: 6 Sorting Algorithms Implementations

1. Bubble Sort (Optimized with Swapped Flag)

c

---

2. Selection Sort

c

---

3. Insertion Sort

c

---

4. Quick Sort (Lomuto Partitioning - Divide & Conquer)

c

---

5. Merge Sort (Divide & Conquer)

c

---

4. Master Comparison Table of Sorting Algorithms

AlgorithmBest TimeAverage TimeWorst TimeAuxiliary SpaceStability
Bubble SortO(N)O(N^2)O(N^2)O(1)Stable
Selection SortO(N^2)O(N^2)O(N^2)O(1)Unstable
Insertion SortO(N)O(N^2)O(N^2)O(1)Stable
Quick SortO(N \log N)O(N \log N)O(N^2)O(\log N)Unstable
Merge SortO(N \log N)O(N \log N)O(N \log N)O(N)Stable
Shell SortO(N \log N)O(N^{1.3})O(N^2)O(1)Unstable