BFS in binary tree
问题 I'm trying to write the codes for breadth-first search in binary tree. I've stored all the data in a queue, but I can't figure out how to travel to all nodes and consume all their children. Here's my code in C: void breadthFirstSearch (btree *bt, queue **q) { if (bt != NULL) { //store the data to queue if there is if (bt->left != NULL) enqueue (q, bt->left->data); if (bt->right != NULL) enqueue (q, bt->right->data); //recursive if (bt->left != NULL) breadthFirstSearch (bt->left, q); if (bt-