From 25eaf0224af38fcd50675e196aed04d8c2616ec7 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Wed, 5 Aug 2015 05:45:30 -0400 Subject: [PATCH] Simplified check to determine if there are items in the queue. --- graphs_trees/tree_bfs/bfs_solution.ipynb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/graphs_trees/tree_bfs/bfs_solution.ipynb b/graphs_trees/tree_bfs/bfs_solution.ipynb index 46f76f3..6fdf041 100644 --- a/graphs_trees/tree_bfs/bfs_solution.ipynb +++ b/graphs_trees/tree_bfs/bfs_solution.ipynb @@ -34,8 +34,6 @@ "## Constraints\n", "\n", "* Can we assume we already have a Node class with an insert method?\n", - " * Yes\n", - "* Can we use collections.deque for the queue?\n", " * Yes" ] }, @@ -98,7 +96,7 @@ "def bfs(root, visit_func):\n", " queue = deque()\n", " queue.append(root)\n", - " while len(queue) > 0:\n", + " while queue:\n", " node = queue.popleft()\n", " visit_func(node.data)\n", " if node.left is not None:\n",