* fix: changed test text to use should * fix: corrected typo Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: corrected typo Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: corrected typo Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: use singular of verb Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: changed punctuation Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: reworded test text Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
3.0 KiB
3.0 KiB
id, title, challengeType, forumTopicId
id | title | challengeType | forumTopicId |
---|---|---|---|
587d825b367417b2b2512c8b | Remove an Element from a Max Heap | 1 | 301710 |
Description
Instructions
Tests
tests:
- text: The MaxHeap data structure should exist.
testString: assert((function() { var test = false; if (typeof MaxHeap !== 'undefined') { test = new MaxHeap() }; return (typeof test == 'object')})());
- text: MaxHeap should have a method called print.
testString: assert((function() { var test = false; if (typeof MaxHeap !== 'undefined') { test = new MaxHeap() } else { return false; }; return (typeof test.print == 'function')})());
- text: MaxHeap should have a method called insert.
testString: assert((function() { var test = false; if (typeof MaxHeap !== 'undefined') { test = new MaxHeap() } else { return false; }; return (typeof test.insert == 'function')})());
- text: MaxHeap should have a method called remove.
testString: assert((function() { var test = false; if (typeof MaxHeap !== 'undefined') { test = new MaxHeap() } else { return false; }; return (typeof test.remove == 'function')})());
- text: The remove method should remove the greatest element from the max heap while maintaining the max heap property.
testString: assert((function() { var test = false; if (typeof MaxHeap !== 'undefined') { test = new MaxHeap() } else { return false; }; test.insert(30); test.insert(300); test.insert(500); test.insert(10); let result = []; result.push(test.remove()); result.push(test.remove()); result.push(test.remove()); result.push(test.remove()); return (result.join('') == '5003003010') })());
Challenge Seed
var MaxHeap = function() {
// change code below this line
// change code above this line
};
Solution
// solution required