Total Pageviews

Monday, August 31, 2026

🗑️ ARRAY DELETION AT FRONT

🗑️ ARRAY DELETION AT FRONT
Delete the first element and shift every remaining element one position to the LEFT

📥 Enter Array Values

🎬 Step-by-Step Animation

Enter values and press START DELETE.

📊 Operation Statistics

Array Size 0
Shifts Completed 0

📝 Step-by-Step Explanation

🧮 Mathematical Representation

Original Array
A = [10, 20, 30, 40, 50]

First element is deleted:
DELETE A[0]

Deleted value:
10

Now shift the remaining elements LEFT:

A[0] ← A[1]

20 moves from index 1 to index 0.

A[1] ← A[2]

30 moves from index 2 to index 1.

A[2] ← A[3]

40 moves from index 3 to index 2.

A[3] ← A[4]

50 moves from index 4 to index 3.

Finally:
n = n − 1

Therefore:
[20, 30, 40, 50]

💻 Algorithm

DELETE_FRONT(A,n)

Step 1: Delete the first element.

Step 2: Start from the second element.

Step 3: Move each element one position LEFT.

For: i = 1 to n − 1

Perform: A[i − 1] = A[i]

Step 4: n = n − 1

⏱️ Time and Space Complexity

Time Complexity O(n)
Number of Shifts n − 1

🎯 Final Result

Result will appear here.

⚡ QUICK SORT VISUALIZER

```
⚡ QUICK SORT VISUALIZER
Choose Pivot • Partition • Compare • Swap • Recursively Sort
```
```

📥 Enter Your Data

```
```

📊 Current Array

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

📈 Live Statistics

Recursion Level 0
Comparisons 0
Swaps 0
Partitions 0
Steps 0
```
```

🔀 Partition Visualization

```
```

📝 Step-by-Step Explanation

1
Quick Sort selects a pivot and rearranges the elements so that smaller values go to the left and larger values go to the right.
```
```

🧮 Quick Sort Mathematics

Choose a pivot:
pivot = A[high]

Start:
i = low − 1

For every element A[j]:
If A[j] ≤ pivot
then:
i = i + 1
and swap:
A[i] ↔ A[j]

Finally:
A[i+1] ↔ A[high]

The pivot is now in its correct position.
```
```

🔢 Complete Mathematical Example

Initial Array:
10, 7, 8, 9, 1, 5

Choose last element as pivot:
pivot = 5

Start:
i = −1

Compare 10 with 5:
10 ≤ 5 → False
No swap.

Compare 7 with 5:
7 ≤ 5 → False
No swap.

Compare 8 with 5:
8 ≤ 5 → False
No swap.

Compare 9 with 5:
9 ≤ 5 → False
No swap.

Compare 1 with 5:
1 ≤ 5 → True
i = 0
Swap A[0] and A[4]:
1, 7, 8, 9, 10, 5

Finally swap pivot 5 with A[1]:
1, 5, 8, 9, 10, 7

Pivot 5 is now in its final position.

Left partition:
[1]

Right partition:
[8,9,10,7]

Quick Sort recursively processes both partitions.
```
```

⚙️ How Quick Sort Works

1
Choose a Pivot: Select one element as the pivot. This visualizer uses the last element.
2
Partition: Move elements smaller than or equal to the pivot toward the left side.
3
Move larger elements toward the right side.
4
Place the pivot between the two partitions.
5
Recursively apply Quick Sort to the left partition.
6
Recursively apply Quick Sort to the right partition.
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Very fast on average.
• Average time complexity is O(n log n).
• Can be implemented in-place.
• Usually performs well in practical applications.
Disadvantages
• Poor pivot selection can produce O(n²) time.
• Standard Quick Sort is not stable.
• Recursive implementation requires stack space.
```
```

⏱️ Time & Space Complexity

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

🎯 Pivot Concept

A good pivot divides the array into two approximately equal parts.

Example:
[2, 4, 5] | 6 | [7, 8, 9]

This produces approximately balanced partitions and gives:
O(n log n) average performance.

A poor pivot may produce:
[] | 1 | [2,3,4,5,6,7]

Repeated poor partitions can lead to:
O(n²)
```

🏔️ 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)
```