Why Is Heap Implemented Using Array Representations Than #492
Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities?</p> <pre><code class="language-java"> for binary heap -insert: O(log n) -delete min: O(log n) for a tree -insert: O(log n) -delete: O(log n) </code></pre> <p>Then why go with array representation when both are having same values ?
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Binary Trees - Binary Trees using Array - Quiz No.1.
Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities?
for binary heap -insert: O(log n) -delete min: O(log n) for a tree -insert: O(log n) -delete: O(log n)
Then why go with array representation when both are having same values ?
arrays can store trees which are complete and heaps are not complete
lists representation takes more memory hence memory efficiency is less and go with arrays and arrays have better caching
lists have better caching
In lists insertion and deletion is difficult
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes