From 478a8c80c07aeff625eed3f611e1087e3b186361 Mon Sep 17 00:00:00 2001 From: Ahmed Silat <105588821+ahmedsilat44@users.noreply.github.com> Date: Tue, 27 Sep 2022 19:15:50 +0500 Subject: [PATCH] Fixed typos in MinHeap (#851) --- docs/en/Tree/min-heap.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/Tree/min-heap.md b/docs/en/Tree/min-heap.md index 307021ab..789e54dc 100644 --- a/docs/en/Tree/min-heap.md +++ b/docs/en/Tree/min-heap.md @@ -27,19 +27,19 @@ 3. If the parent is greater than the element, swap them (move the element one level up), then go to step two. 4. Stop if the parent is less or equal. -> **Note:** second and third steps sift the element up the tree, until correct order of elements is achieved. +> **Note:** second and third steps shift the element up the tree, until correct order of elements is achieved. **remove min** 1. Replace the root with the rightmost element on the deepest level. The new root is now current element. 2. Compare the current element with its smallest child. 3. If the element is greater than its smallest child, swap the element with its smallest child (move the element one level deeper), and go to step 2. 4. If both children are greater or equal to the current element, stop. -> **Note:** second and third steps sift the element down the tree until correct order of elements is achieved. +> **Note:** second and third steps shift the element down the tree until correct order of elements is achieved. ## Example - **Inserting** elements 4, 10, 2, 22, 45, 18
Output: 2 10 4 22 45 18
Explanation: The numbers are stored subsequently. 2 is the root, 10 and 4 are its children. The children of 10 are 22 and 45. The only child of 4 is 18. -- **Deleting** the minimum in 2 10 4 22 45 18
Output: 4 10 18 22 45
Explanation: First, 2 is swapped with 18. Then, 18 is sifted down the tree, until the elements are in correct order. The size of the heap is reduced by 1. +- **Deleting** the minimum in 2 10 4 22 45 18
Output: 4 10 18 22 45
Explanation: First, 2 is swapped with 18. Then, 18 is shifted down the tree, until the elements are in correct order. The size of the heap is reduced by 1. ## Implementation