From 474ae28d72a0e30d88ba40f3e35dc0387e9d9308 Mon Sep 17 00:00:00 2001 From: Ty Mick Date: Mon, 31 Aug 2020 01:15:58 -0400 Subject: [PATCH] Fix number of noun (#38833) Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> --- .../insert-an-element-into-a-max-heap.english.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curriculum/challenges/english/10-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md b/curriculum/challenges/english/10-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md index 0dc85838de..184bf7939e 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md +++ b/curriculum/challenges/english/10-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md @@ -26,7 +26,7 @@ Once you wrap your head around the math, using an array representation is very u Instructions: Here we will create a max heap. Start by just creating an insert method which adds elements to our heap. During insertion, it is important to always maintain the heap property. For a max heap this means the root element should always have the greatest value in the tree and all parent nodes should be greater than their children. For an array implementation of a heap, this is typically accomplished in three steps:
  1. Add the new element to the end of the array.
  2. -
  3. If the element is larger than its parents, switch them.
  4. +
  5. If the element is larger than its parent, switch them.
  6. Continue switching until the new element is either smaller than its parent or you reach the root of the tree.
Finally, add a print method which returns an array of all the items that have been added to the heap.