All pastes #733907 Raw Edit

Untitled

public java v1 · immutable
·published 2007-10-12 05:14 UTC
rendered paste body
public void insertThreaded(E x) {	Node current = root; //Do you use the name root? generally you dont use root for transversing. We start it off at root and transverse from there.		while(((x.compareTo(current.data)<0) ? current.leftChild != null : current.rightChild != null ))	{		if(x.compareTo(current.data) == 0)			return; //trees do not have duplicates!		current = ((x.compareTo(current.data) < 0) ? current.leftChild : current.rightChild);	}		//and create the new node and call it day. 	if(x.compareTo(current.data) <0)		current.leftChild = new Node(x);	else		current.rightChild = new Node(x);}