Skip to content

Adding BFS-1 solutions#1622

Open
subbu4061 wants to merge 1 commit intosuper30admin:masterfrom
subbu4061:master
Open

Adding BFS-1 solutions#1622
subbu4061 wants to merge 1 commit intosuper30admin:masterfrom
subbu4061:master

Conversation

@subbu4061
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Strengths:

  • You provided two correct solutions, showing versatility in approach.
  • The code is well-commented, explaining the time and space complexity and the logic behind each solution.
  • The solutions are efficient and meet the problem constraints.

Areas for Improvement:

  • While the DFS solution is correct, it uses recursion which might lead to a stack overflow for very deep trees (though the problem constraints make this unlikely). The BFS solution is generally preferred for level order traversal because it directly mirrors the problem's requirement to process nodes by level.
  • In the DFS solution, the variable name inter could be improved to something more descriptive, like levelList or currentLevel.
  • The helper function in the DFS solution has a return statement at the end, which is unnecessary since it is a void function.
  • The course-schedule solution was included in the same file, which is not related to the binary tree level order traversal problem. It's better to separate solutions for different problems into different files.

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