Task: A ternary heap is like a binary heap, except instead of each node having a max of two children, each node has a max of three children. Given a ternary min heap, return true if it is a valid hea...
Task: A ternary heap is like a binary heap, except instead of each node having a max of two children, each node has a max of three children. Given a ternary min heap, return true if it is a valid heap. That is, it satisfies the heap property (the parent is less than all of its children) Requirements: Implement an isValidHeap function to determine whether a particular array of integers constitutes a valid ternary min-heap. bool isValidHeap(int arr[])// example declaration Examples If arr(4,7,10,6,12,9) then isValidHeap(arr) should return true If arr(5,10,9,4,12) then isValidHeap(arr) should return false If arr(10 then isValidHeap(arr) should return true Use the starter code in Moodle and the implementations you have prepared. Write a main function that creates an array of integers, then calls the function defined above to demonstrate the method. Call it on multiple arrays to show that it works in all cases, and print out the results.
Task: A ternary heap is like a binary heap, except instead of each node having a max of two children, each node has a max of three children. Given a ternary min heap, return true if it is a valid heap. That is, it satisfies the heap property (the parent is less than all of its children) Requirements: Implement an isValidHeap function to determine whether a particular array of integers constitutes a valid ternary min-heap. bool isValidHeap(int arr[])// example declaration Examples If arr(4,7,10,6,12,9) then isValidHeap(arr) should return true If arr(5,10,9,4,12) then isValidHeap(arr) should return false If arr(10 then isValidHeap(arr) should return true Use the starter code in Moodle and the implementations you have prepared. Write a main function that creates an array of integers, then calls the function defined above to demonstrate the method. Call it on multiple arrays to show that it works in all cases, and print out the results.