public void insertId(String id)
{
String converted_id = id.toLowerCase();
Id new_node;
if (find(converted_id))
return;
else
{
new_node = new Id(converted_id);
if (parent == null)
root = new_node;
else if (converted_id.compareTo(parent.key) < 0)
parent.left = new_node;
else
parent.right = new_node;[/where the assignment that creates a loop happens, for my .txt file]
}
}
/////////////////////////////////////////////
public boolean find(String data)
{
Id node = root;
boolean found = false;
parent = null;
while (!found && node != null)
{
parent = node;
if (data.compareTo(node.key) < 0)
node = node.left;
else if (data.compareTo(node.key) > 0)
node = node.right;
else
{
found = true;
//node.id_list.insertAfter(data.toLowerCase());
return found;
}
}
return found;
}
I wish I could have showed this in a nicely formatted layout, but this site would not conform to my spacing.
Edited by macosxnerd101: Please use code tags, like so:

New Topic/Question
Reply


MultiQuote



|