Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Add(int i) {
- boolean fertig = false;
- Node h;
- if(root == null) {
- root = new Node(i);
- return;
- }
- else {
- h = root;
- while(!fertig) {
- if(i>h.value && h.right != null) {
- h=h.right;
- }
- if(i<h.value && h.left != null) {
- h=h.left;
- }
- if(i>h.value && h.right == null) {
- h.right = new Node(i);
- fertig = true;
- }
- if(i<h.value && h.left == null) {
- h.left = new Node(i);
- fertig = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement