-
Notifications
You must be signed in to change notification settings - Fork 268
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
Conversation
--update : add test file for merge-two-sorted-arrays
BinarySearch test
2nd approach for product-of-elements
product-of-element.test.js
Re-implementation of Queue
Problems involving Queues
Add jumpSearch and Tests
* add solution to sort a stack problem * update README.md * add time compexity
BST unit test for delete()
Added tests for BST insertion
There was a problem hiding this 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.
const tree = { | ||
data: 10, | ||
left: { data: 30, left: { data: 20 } }, | ||
right: { data: 15, right: { data: 5 } }, | ||
}; |
There was a problem hiding this comment.
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
expect(tree).toEqual({ | ||
data: 15, | ||
left: { | ||
data: 10, | ||
left: { | ||
data: 5, | ||
}, | ||
}, | ||
right: { | ||
data: 20, | ||
right: { | ||
data: 30, | ||
}, | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
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
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); | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
@TheSTL please look into this. |
@ashokdey I have made some changes as per your review. Please review it whenever possible. |
- Fixed ESlint errors - throw error for invalid string
Closing this PR because of messed up Author info. Will open a new one for the same |
No description provided.