Ahsan (FA23 BAI 020)
Ahsan (FA23 BAI 020)
class Max_Heap {
public int[] heap;
public int size;
public int maxsize;
heap[size] = key;
int current = size;
size++;
printHeap();
}
int[] elements = {21, 27, 22, 23, 45, 35, 4, 19, 42};
OUTPUT:
Question no 2:
Code:
package DSLabTerminalQ2;
import java.util.LinkedList;
import java.util.Queue;
class BinaryNode {
int value;
BinaryNode left, right;
class BinaryTree {
BinaryNode root;
else {
BinaryNode minNode = getMin(node.right);
node.value = minNode.value;
node.right = deleteNode(node.right, minNode.value);
}
}
return node;
}
while (!queue.isEmpty()) {
BinaryNode current = queue.remove();
System.out.print(current.value + " ");
if (current.left != null) queue.add(current.left);
if (current.right != null) queue.add(current.right);
}
System.out.println();
}
}
OUTPUT: