algorithm breadthfirst(root preroot is the root node of the bst postthe nodes in the bst have been visited in breadth first order queue while root yield root value if root left enqueue(root left end if if root right enqueue(root right end if if ! isempty( root dequeue( else root end if end while end breadthfirst summary binary search tree is good solution when you need to represent types that are ordered according to some custom rules inherent to that type with logarithmic insertionlookupand deletion it is very effecient traversal remains linearbut there are many ways in which you can visit the nodes of tree trees are recursive data structuresso typically you will find that many algorithms that operate on tree are recursive the run times presented in this are based on pretty big assumption that the binary search tree' left and right subtrees are reasonably balanced we can only attain logarithmic run times for the algorithms presented earlier when this is true binary search tree does not enforce such propertyand the run times for these operations on pathologically unbalanced tree become linearsuch tree is effectively just linked list later in ss we will examine an avl tree that enforces self-balancing properties to help attain logarithmic run times