Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement Binary Tree to Binary Search Tree Conversion #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
k88manish wants to merge 273 commits into knaxus:master from k88manish:master
Closed

Implement Binary Tree to Binary Search Tree Conversion #95

k88manish wants to merge 273 commits into knaxus:master from k88manish:master

Conversation

Copy link
Contributor

@k88manish k88manish commented Oct 17, 2019

No description provided.

ashokdey reacted with thumbs up emoji
ashokdey and others added 30 commits January 4, 2019 13:28
--update : add test file for merge-two-sorted-arrays
TheSTL and others added 12 commits October 13, 2019 19:16
* add solution to sort a stack problem
* update README.md
* add time compexity
Copy link
Member

@ashokdey ashokdey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k88manish please go through the changes requested and make the changes where required.

Comment on lines 3 to 7
const tree = {
data: 10,
left: { data: 30, left: { data: 20 } },
right: { data: 15, right: { data: 5 } },
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the Node structure and adhere to it for all the things you do with BST.
Find the Node Implementation here: BST Node

Comment on lines 12 to 27
expect(tree).toEqual({
data: 15,
left: {
data: 10,
left: {
data: 5,
},
},
right: {
data: 20,
right: {
data: 30,
},
},
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the tree traversal method to verify the result

Comment on lines 20 to 32
function storeInorder(root, inorder) {
// Base case
if (!root) return;

// First store the left subtree
storeInorder(root.left, inorder);

// Append root's data
inorder.push(root.data);

// Store right subtree
storeInorder(root.right, inorder);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to return an array instead of accepting an array as an argument. For help, you can go through the various traversal algorithms and problems on BST from the README

storeInorder(root.right, inorder);
}

// Helper function that copies of sorted array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more detailed information here

Copy link
Member

@TheSTL please look into this.

Copy link
Contributor Author

@ashokdey I have made some changes as per your review. Please review it whenever possible.

Manish Kumar and others added 3 commits October 20, 2019 15:37
Copy link
Contributor Author

Closing this PR because of messed up Author info. Will open a new one for the same

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

@TheSTL TheSTL Awaiting requested review from TheSTL

@ashokdey ashokdey Awaiting requested review from ashokdey

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /