By looking at the values it is clear that It is a Min-Heap Data structures. We know that Heap Data structures are stored in the array.
$\implies $ Delete procedure for Min-Heap Data Structure (If you already know the value and position of the node):
- Replace that node with the last element of that tree.
- Apply Heapify property on that node.
For Example, Let If I want to delete $1$, then I will replace that with $27$. and apply heapify on that node. Or if i want to delete $5$ then also I will replace that with $27$, and apply heapify on that node.
Time Complexity: In this case, time complexity will not be more than $O(\log n)$.
$\implies $ Delete procedure for Min-Heap Data Structure (If you know the value but not position) :
- Find the position of the number by sequential search. (In the worst case it will take $O(n)$ time).
- Replace that node with the last element of that tree.
- Apply heapify property at that node.
Time Complexity: Wort time complexity of this algorithm will be $\mathbf{O(n + \log n)}$ i.e. $\mathbf{O(n)}$.
Note: This is a standard problem of Minimum element deletion from the Min-heap tree. The minimum element always resides at top (Root node). We just replace that value with the last element of the tree and apply heapify at the root node. The time complexity of that algorithm is $\mathbf{O(\log n)}$.
Here I have written the second method only to show that if we have to delete any of the nodes, and we just know the value but not the position. Since in question it is mentioned that Arbitrary node.