Convert Array to Min Heap Task
Given an array 'ARR' of integers with 'N' elements, you need to convert it into a min-binary heap.
A min-binary heap is a complete binary tree where each internal node's value is smaller than or equal to its children's value.
Example:
Input:
ARR = [3, 1, 6, 5, 2, 4]
Output:
Checker prints 1 if 'ARR' is a valid min-heap after modification, otherwise 0
Explanation:
Your task is to modify the array 'ARR' to satisfy the min-heap properties and test if the checker can verify it as a valid min-heap by returning 1.
- The input follows a 0-based indexing system.
- Ensure the left child of the i-th node is at (2*i + 1)-th index, if it exists.
- Ensure the right child of the i-th node is at (2*i + 2)-th index, if it exists.
- You only need to update the array, not create a tree.
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 104
-109 ≤ ARR[i] ≤ 109
- Time Limit: 1 sec
Note:
You don't have to print anything. Just implement the function to convert the array 'ARR' into a min-heap.

AnswerBot
4mo
Convert the given array into a min-binary heap by modifying the array elements.
Iterate through the array and heapify each node starting from the last non-leaf node to the root node.
For each node, comp...read more
Help your peers!
Add answer anonymously...
VMware Software Member Technical Staff interview questions & answers
A Member Technical Staff was asked Q. Convert Array to Min Heap Task Given an array 'ARR' of integers with 'N' element...read more
A Member Technical Staff was asked Q. Tower of Hanoi Problem Statement You have three rods numbered from 1 to 3, and '...read more
A Member Technical Staff was asked Q. What is a page fault?
Popular interview questions of Member Technical Staff
A Member Technical Staff was asked Q1. Convert Array to Min Heap Task Given an array 'ARR' of integers with 'N' element...read more
A Member Technical Staff was asked Q2. Tower of Hanoi Problem Statement You have three rods numbered from 1 to 3, and '...read more
A Member Technical Staff was asked Q3. What is a page fault?
>
VMware Software Member Technical Staff Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

