Total Pageviews

Monday, August 31, 2026

🔀 MERGE SORT VISUALIZER

```
🔀 MERGE SORT VISUALIZER
Divide • Conquer • Merge • Step-by-Step Animation
```
```

📥 Enter Your Data

```
```

📊 Current Array

Enter values and press START SORT.
```
```

📈 Live Statistics

Current Level 0
Comparisons 0
Merges 0
Current Step 0
Array Size 0
```
```

🌳 Divide Structure

```
```

📝 Step-by-Step Explanation

1
Merge Sort follows the Divide and Conquer strategy. The array is repeatedly divided into smaller parts until every part contains one element.
```
```

🧮 Merge Sort Mathematics

Divide the array:
mid = ⌊(low + high) / 2⌋

Left part:
A[low ... mid]

Right part:
A[mid+1 ... high]

Then merge the two sorted parts by repeatedly selecting the smaller front element.
```
```

🔢 Complete Mathematical Example

Initial Array:
38, 27, 43, 3

Calculate midpoint:
mid = (0 + 3) / 2 = 1

Divide:
Left = 38, 27
Right = 43, 3

Divide again:
[38,27] → [38] [27]
[43,3] → [43] [3]

Merge [38] and [27]:
27 < 38
Result: [27,38]

Merge [43] and [3]:
3 < 43
Result: [3,43]

Final Merge:
Compare 27 and 3 → choose 3
Compare 27 and 43 → choose 27
Compare 38 and 43 → choose 38
Remaining element → 43

Final Result:
3, 27, 38, 43
```
```

💡 How Merge Sort Works

1
Divide: Split the array into two approximately equal parts.
2
Continue dividing each part until every subarray contains only one element.
3
A single element is already considered sorted.
4
Merge: Compare the front elements of two sorted subarrays.
5
Copy the smaller element into the result.
6
Continue until both subarrays have been completely merged.
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Guaranteed O(n log n) time complexity.
• Very effective for large datasets.
• Stable sorting algorithm.
• Works particularly well with linked lists and external sorting.
−
Disadvantages
• Requires additional memory for merging.
• More complicated than Bubble Sort.
• For small arrays, simpler algorithms can sometimes be preferable.
```
```

⏱️ Time & Space Complexity

Best Case O(n log n)
Average Case O(n log n)
Worst Case O(n log n)
Extra Space O(n)
```

🔵 BUBBLE SORT VISUALIZER

```
🔵 BUBBLE SORT VISUALIZER
Interactive • Step-by-Step • Comparison • Swap Animation
```
```

📥 Enter Your Data

Animation Speed:
```
```

📊 Array Visualization

Enter your values and press START SORT.
```
```

📈 Live Statistics

Pass 0
Comparison 0
Swaps 0
Current Index -
Remaining -
```
```

📝 Step-by-Step Explanation

1
Bubble Sort compares two adjacent elements. If the left element is greater than the right element, they are swapped.
```
```

🧮 Bubble Sort Mathematics

Compare adjacent elements:
A[j] > A[j+1]

If TRUE:
Swap A[j] and A[j+1]

Example:
64 > 34
Therefore:
64 ↔ 34
Array becomes:
34, 64, ...
```
```

🔢 Complete Example

Initial Array:
5, 3, 8, 4

Pass 1

Compare 5 and 3:
5 > 3 → Swap
3, 5, 8, 4

Compare 5 and 8:
5 < 8 → No Swap
3, 5, 8, 4

Compare 8 and 4:
8 > 4 → Swap
3, 5, 4, 8

Largest element 8 has moved to the end.

Pass 2
Compare 3 and 5 → No Swap
Compare 5 and 4 → Swap
3, 4, 5, 8

Final Sorted Array:
3, 4, 5, 8
```
```

💡 Why Is It Called Bubble Sort?

↑
During every pass, larger elements move toward the right side of the array.

The larger values appear to "bubble" toward the end of the array.
```
```

🔄 Algorithm

Start
↓
Compare adjacent elements
↓
Is A[j] > A[j+1]?
↓
YES → Swap
NO → Continue
↓
Complete one pass
↓
Largest unsorted element reaches its position
↓
Repeat
↓
Array Sorted
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Very easy to understand.
• Simple to implement.
• Requires very little additional memory.
• Useful for teaching sorting concepts.
• Can stop early when no swaps occur.
−
Disadvantages
• Slow for large datasets.
• Performs many comparisons.
• Usually less efficient than insertion sort, merge sort, or quicksort for larger inputs.
```
```

⏱️ Time & Space Complexity

Best Case O(n)
Average Case O(n²)
Worst Case O(n²)
Space Complexity:
O(1)
Bubble Sort is an in-place sorting algorithm.
```

DOUBLE HASHING VISUALIZER

```
🔷 DOUBLE HASHING VISUALIZER
Hashing • Collision Resolution • Two Hash Functions • Step-by-Step Animation
```
```

📥 Hash Table Configuration

```
```

🗂️ Hash Table

🔵 Current Probe
🟡 Collision
🟢 Found / Inserted
🔴 Deleted
```
```

📈 Live Statistics

Operation -
h₁(k) -
h₂(k) -
Current Index -
Collisions 0
Probes 0
Enter a value and select an operation.
```
```

📝 Step-by-Step Explanation

1
Double Hashing uses two hash functions. The first function gives the starting position and the second function determines the jump size after a collision.
```
```

🧮 Double Hashing Formula

First Hash Function:
h₁(k) = k mod m

Second Hash Function:
h₂(k) = R − (k mod R)

Final Probe Formula:
h(k,i) = (h₁(k) + i × h₂(k)) mod m

where:
k = key    m = table size    R = smaller prime number
i = probe number
```
```

🔢 Complete Mathematical Example

Table Size: m = 11

Choose: R = 7

Key: 27

First Hash:
h₁(27) = 27 mod 11 = 5

Second Hash:
h₂(27) = 7 − (27 mod 7)
= 7 − 6 = 1

Probe 0:
(5 + 0 × 1) mod 11 = 5

Suppose Index 5 is occupied.
⚠️ Collision!

Probe 1:
(5 + 1 × 1) mod 11 = 6

If Index 6 is occupied:
Probe 2:
(5 + 2 × 1) mod 11 = 7

Therefore:
Probe Sequence: 5 → 6 → 7 → ...
```
```

💡 How Double Hashing Works

1
Calculate the first hash function h₁(k).
2
Check the position returned by the first hash.
3
If the position is occupied, a collision occurs.
4
Calculate the second hash function h₂(k).
5
Use the second hash value as the jump size.
6
Continue using (h₁(k) + i × h₂(k)) mod m until an appropriate position is found.
```
```

⚔️ Comparison with Other Probing Methods

Linear Probing
h(k,i) = (h(k) + i) mod m
Example: 5 → 6 → 7 → 8

Quadratic Probing
h(k,i) = (h(k) + i²) mod m
Example: 5 → 6 → 9 → 4

Double Hashing
h(k,i) = (h₁(k) + i × h₂(k)) mod m
Example: 5 → 8 → 0 → 3

Double hashing generally provides a more varied probe sequence and helps reduce clustering.
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Uses two hash functions.
• Provides a more distributed probe sequence.
• Reduces primary clustering.
• Usually performs better than simple linear probing when the hash functions and table size are chosen well.
−
Disadvantages
• More complex than linear probing.
• Requires two suitable hash functions.
• The second hash function must not produce a zero step.
• Table size and hash-function choices affect performance.
```
```

⏱️ Complexity

Average Search O(1)
Average Insert O(1)
Worst Case O(n)
```

🔷 QUADRATIC PROBING VISUALIZER

```
🔷 QUADRATIC PROBING VISUALIZER
Hashing • Collision Resolution • Quadratic Probing • Animation
```
```

📥 Hash Table Configuration

```
```

🗂️ Hash Table

🔵 Current Probe
🟡 Collision
🟢 Found / Inserted
🔴 Deleted
```
```

📈 Live Statistics

Operation -
Hash Index -
Current Index -
Collisions 0
Probes 0
Enter a value and select an operation.
```
```

📝 Step-by-Step Explanation

1
Quadratic Probing resolves a collision by checking positions using the square of the probe number.
```
```

🧮 Quadratic Probing Formula

First calculate:
h(k) = k mod m

If collision occurs:
hi(k) = (h(k) + i²) mod m

Probe sequence:
h(k), h(k)+1², h(k)+2², h(k)+3², ...

where
k = key    m = table size    i = probe number
```
```

🔢 Complete Mathematical Example

Table Size = 10

Insert KEY = 25
h(25) = 25 mod 10
= 5

Therefore, try Index 5.

Suppose Index 5 is occupied.
Collision!

Probe 1:
(5 + 1²) mod 10 = 6

If Index 6 is occupied:
Probe 2:
(5 + 2²) mod 10 = 9

If Index 9 is occupied:
Probe 3:
(5 + 3²) mod 10 = 14 mod 10 = 4

So the probe sequence is:
5 → 6 → 9 → 4
```
```

💡 How Quadratic Probing Works

1
Calculate the initial hash position using h(k) = k mod m.
2
Check whether the calculated position is empty.
3
If it is occupied, a collision occurs.
4
Instead of checking the immediate next position, calculate the next position using i².
5
Continue with i = 1, 2, 3, 4... until an available position is found.
6
Insert the key into the first suitable position.
```
```

⚔️ Linear vs Quadratic Probing

Linear Probing
hi(k) = (h(k) + i) mod m

Checks positions:
5 → 6 → 7 → 8 → 9



Quadratic Probing
hi(k) = (h(k) + i²) mod m

Checks positions:
5 → 6 → 9 → 4 → ...

Quadratic probing spreads the probes farther apart and helps reduce primary clustering.
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Reduces primary clustering compared with linear probing.
• Does not require linked lists.
• Uses the same hash table structure.
• Generally provides efficient average-case operations when the load factor is controlled.
−
Disadvantages
• Secondary clustering can still occur.
• The probe sequence depends on the table size.
• Choosing a suitable table size is important.
• Performance decreases when the table becomes highly full.
```
```

⏱️ Complexity

Average Search O(1)
Average Insert O(1)
Worst Case O(n)
```