Skip to content

Latest commit

 

History

History
38 lines (23 loc) · 1.73 KB

File metadata and controls

38 lines (23 loc) · 1.73 KB

Tree Breadth First

This project implements a breadth first function taking in tree as an argument and returning a list of all values in the tree in the order they were encountered using a Queue.

Features:

  • Queue
    • breadth_first
  • Node

Whiteboard Process

Whiteboard

Approach & Efficiency

Reviewed the example, pseudocode and tests provided, whiteboarded test cases and visualized the output. Added the code then used chatgpt to assist on Big O analysis.

Resources:

Big O

BinaryTree

Time Complexity: O(n), where n is the number of nodes in the tree. Each node is visited exactly once, making the time complexity linear in the size of the tree.

Space Complexity: O(w), where w is the maximum width of the tree. This represents the worst-case scenario where the queue stores the maximum number of nodes at any level of the tree.

Source: ChatGPT

Solution

tree_breadth_first.py and queue.py

test_tree_breadth_first.py and test_queue.py