Skip to content

Completed Trees1 - #1759

Open
Keerthi0910 wants to merge 4 commits into
super30admin:masterfrom
Keerthi0910:master
Open

Completed Trees1#1759
Keerthi0910 wants to merge 4 commits into
super30admin:masterfrom
Keerthi0910:master

Conversation

@Keerthi0910

Copy link
Copy Markdown

@super30admin

Copy link
Copy Markdown
Owner

Validate Binary Search Tree (Problem1.java)

Strengths:

  • Your solution correctly implements the in-order traversal approach to validate a BST.
  • The logic is sound and matches the reference solution.
  • You added a nice optimization with the if(flag) checks to short-circuit the traversal once an invalid BST is detected.
  • The code is readable and well-structured.

Areas for improvement:

  • The comments at the top of your file are incorrect. You wrote "O(n) space complexity" and "O(1) time complexity", but the actual complexities are O(n) time and O(h) space (where h is the height of the tree due to the recursion stack).
  • Consider making the helper method private instead of public since it's an internal helper method.
  • The if(flag) checks are a good optimization, but be aware that in the worst case (when the tree is valid), they don't provide any benefit. They're only useful when an invalid BST is detected early.

VERDICT: PASS


Construct Binary Tree from Preorder and Inorder Traversal (Problem2.java)

[Feedback for the instructor]

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