Skip to content

Completed BFS-1#1651

Open
Sanket-S-Kale wants to merge 1 commit into
super30admin:masterfrom
Sanket-S-Kale:master
Open

Completed BFS-1#1651
Sanket-S-Kale wants to merge 1 commit into
super30admin:masterfrom
Sanket-S-Kale:master

Conversation

@Sanket-S-Kale

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Binary Tree Level Order Traversal (Problem1-DFS.py)

Strengths:

  • Excellent use of DFS as an alternative approach to the classic BFS solution
  • Clear and comprehensive comments explaining each step
  • Good variable naming (e.g., level, result)
  • Proper handling of edge cases (empty tree returns empty list)
  • Correct use of Python's nonlocal keyword

Areas for Improvement:

  • The solution is already quite optimal. One minor suggestion: you could consider using result.append([]) instead of result.append([root.val]) to be more consistent with the pattern, then append the value separately. This would make the code slightly more uniform.
  • The time complexity comment could be more specific about visiting each node exactly once.

Overall, this is a solid solution that demonstrates a good understanding of tree traversal and recursive problem-solving.

VERDICT: PASS


Course Schedule (Problem1.py)

  1. Wrong Problem: You submitted a solution for "Binary Tree Level Order Traversal" but the problem assigned was "Course Schedule". Please ensure you read and solve the correct problem.

  2. Missing Solution: There is no solution for the Course Schedule problem. You need to implement cycle detection in a directed graph using either DFS or Kahn's algorithm (BFS topological sort).

  3. What you should do:

    • Build an adjacency list from prerequisites
    • Use DFS with three states (unvisited, visiting, visited) to detect cycles
    • Or use BFS with in-degree calculation (Kahn's algorithm)
    • Return false if a cycle is detected, true otherwise
  4. Code Quality (for the submitted problem): Your BFS solution for level order traversal is well-structured with clear comments explaining time/space complexity. The logic is correct for that problem.

VERDICT: NEEDS_IMPROVEMENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants