comp. sci.


binary tree



1.

a binary tree is a simple data structure for organising information that is

	easy to locate, and can be exported in a sorted order.



2.

insert
	if amount < current_node_item

		if left child empty

			add new item as left child
		else

			current_node = left_child
		endif

	else

		if right child empty

			add new item as right child
		else

			current_node = right_child
		endif
	end





3.

export


	if left child not blank
		process left child


	output current node value


	if right child not blank
		process right child



also known as an 'inorder traversal'


this outputs the elements in a sorted order




if approximately balanced, the number of levels is log2( number_items )


if the elements are already in a sorted order before being inserted, the tree is

	very unbalanced, having 'number_items' levels
