Total Pageviews

Monday, August 31, 2026

🏔️ HEAP SORT VISUALIZER

```
🏔️ HEAP SORT VISUALIZER
Build Max Heap • Compare • Swap • Extract Maximum • Sort
```
```

📥 Enter Your Data

```
```

📊 Array Visualization

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

🌳 Max Heap Visualization

```
```

📈 Live Statistics

Phase 0
Comparisons 0
Swaps 0
Heap Size 0
Steps 0
```
```

📝 Step-by-Step Explanation

1
Heap Sort first creates a Max Heap. The largest element is placed at the root.
```
```

🧮 Heap Sort Mathematics

For a node at index i:
Left Child: 2i + 1
Right Child: 2i + 2
Parent: ⌊(i - 1) / 2⌋

For Max Heap:
Parent ≥ Left Child
Parent ≥ Right Child

Root contains the:
Maximum Element
```
```

🔢 Complete Mathematical Example

Initial Array:
4, 10, 3, 5, 1

Start from the last non-leaf node.
Last non-leaf index:
⌊n/2⌋ − 1
For n = 5:
⌊5/2⌋ − 1 = 1

Check index 1:
Parent = 10
Children = 5 and 1
10 is already larger.

Check index 0:
Parent = 4
Children = 10 and 3
Largest = 10
Swap:
10, 4, 3, 5, 1

Now the largest value 10 is at the root.

Extract 10:
Swap root with last element.
1, 4, 3, 5 | 10

Heapify:
5 is larger than 1.
Swap:
5, 4, 3, 1 | 10

Repeat until all elements are extracted.

Final:
1, 3, 4, 5, 10
```
```

⚙️ How Heap Sort Works

1
Build Max Heap: Arrange the array so that every parent is greater than or equal to its children.
2
The largest element is now at the root, index 0.
3
Swap the root with the last element of the unsorted heap.
4
Reduce the heap size by one. The extracted largest element is now sorted.
5
Apply heapify to restore the Max Heap property.
6
Repeat the process until only one element remains.
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Guaranteed O(n log n) time complexity.
• Does not require an additional array like standard Merge Sort.
• Works efficiently for large datasets.
• Uses O(1) auxiliary space when implemented in-place.
Disadvantages
• Usually not stable.
• Heap operations are more difficult to understand than Bubble Sort or Insertion Sort.
• Often has poorer cache behavior than some other O(n log n) sorting algorithms.
```
```

⏱️ Time & Space Complexity

Build Heap O(n)
Best Case O(n log n)
Average Case O(n log n)
Worst Case O(n log n)
Auxiliary Space:
O(1)
Heap Sort is an in-place sorting algorithm.
```

🔀 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)
```