Professional Documents
Culture Documents
ADSAINsertion and Deletion Btree
ADSAINsertion and Deletion Btree
12132006
B-Tree Insertion and Deletion
import java.util.Scanner;
class BTreeNode {
int[] keys;
int t;
BTreeNode[] children;
int n;
boolean leaf;
void traverse() {
int i;
for (i = 0; i < n; i++) {
if (!leaf) {
children[i].traverse();
}
System.out.print(keys[i] + " ");
}
if (!leaf) {
children[i].traverse();
}
}
class BTree {
private BTreeNode root;
private int t;
BTree(int t) {
this.root = null;
this.t = t;
}
void traverse() {
if (root != null) {
root.traverse();
}
}
boolean search(int k) {
if (root != null) {
return root.search(k);
}
return false;
}
}
scanner.close();
}
}
OUTPUT
B-TREE VISUALISATION