-
-
Notifications
You must be signed in to change notification settings - Fork 47.7k
Closed
@riokuma
Description
Feature description
Summary
The current implementation of the breadth_first_search_shortest_path_2.py uses a Python list to simulate a queue. However, using a list for this purpose might be inefficient because removing the first element (pop(0)) has a time complexity of O(n) and affects the overall performance. Python's collections.deque is optimized for such use cases and offers O(1) time complexity for appending and popping from both ends.
Suggested update
Replace the list used as a queue with a collections.deque to improve performance and align with best practices for implementing BFS in Python.