From 29b79482754bb1cf76e233c733cf8d3ca50aef6c Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:51:00 -0700 Subject: [PATCH] Update README.md --- heaps/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heaps/README.md b/heaps/README.md index ada487c..8c967a6 100644 --- a/heaps/README.md +++ b/heaps/README.md @@ -10,13 +10,13 @@
+* heap is a data structure capable of giving you the smallest (or the largest) element in constant time, while adding or removing the smallest (or the largest) element on logarithmic time. + * a heap is a binary tree with these properties: * it must have all of **its nodes in a specific order**, and * its shape must be **complete** (all the levels of the tree must be completely filled except maybe for the last one and the last level must have the left-most nodes filled, always). * a max heap's **root node must** have all its children either **greater than or equal** to its children. a min heap is the opposite. duplicate values are allowed. -* since you always remove the root, insertion and deletion takes `O(log(N))`. the maximum/minimum value in the heap can be obtained with `O(1)` time complexity. - * heaps can be represented with linked lists or queues (arrays) or binary trees. in the case of a tree to array heap: * the parent node index is given by `n / 2` * the left children index is `2 * n`