Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  An array of integers of size n can be convert... Start Learning for Free
An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner is
  • a)
    O(log n)
  • b)
    O(n)
  • c)
    O (n log log n)
  • d)
    O(n log n)
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
An array of integers of size n can be converted into a heap by adjusti...
The above statement is actually algorithm for building a Heap of an input array A.

BUILD-HEAP(A) 
    heapsize := size(A); 
    for i := floor(heapsize/2) downto 1 
        do HEAPIFY(A, i); 
    end for 
END
Upper bound of time complexity is O(n) for above algo
View all questions of this test
Most Upvoted Answer
An array of integers of size n can be converted into a heap by adjusti...
At index ⌊n/2⌋ and moving backwards to the root of the tree at index 1. This process is called "heapifying" the array.

To heapify a node at index i, we compare the value at index i with its two children at indices 2i and 2i+1. If any of the children have a larger value, we swap the value at index i with the larger value. We then recursively heapify the child node that was swapped with the parent node, until the heap property is satisfied.

Here is the pseudocode for heapifying a node at index i:

1. Set largest = i
2. If the left child of i (2i) is larger than i, set largest = 2i
3. If the right child of i (2i+1) is larger than i and larger than the left child, set largest = 2i+1
4. If largest != i, swap the values at indices i and largest
5. Recursively heapify the child node that was swapped with the parent node

To convert an entire array into a heap, we start at index ⌊n/2⌋ and heapify each node moving backwards to the root at index 1. Here is the pseudocode:

1. For i = ⌊n/2⌋ down to 1:
2. Heapify the node at index i

After this process, the array will be a valid heap and satisfy the heap property.
Free Test
Community Answer
An array of integers of size n can be converted into a heap by adjusti...
Because the tree needed to adjust the root node of an array starts withered index node 0and also the number of integers of size of and array
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Question Description
An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer?.
Solutions for An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer?, a detailed solution for An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice An array of integers of size n can be converted into a heap by adjusting the heaps rooted at each internal node of the complete binary tree starting at the node ⌊(n - 1) /2⌋, and doing this adjustment up to the root node (root node is at index 0) in the order ⌊(n - 1)/2⌋, ⌊(n - 3)/ 2⌋, ....., 0. The time required to construct a heap in this manner isa)O(log n)b)O(n)c)O (n log log n)d)O(n log n)Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev