-
Notifications
You must be signed in to change notification settings - Fork 4
Tests/binarysearch #39
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
…ncy; add tests for BST and circular queue behaviors
…move redundant tests
…tView, rightView, and topView; include cases for empty and single-node trees
…rove postfix conversion output
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.
Pull Request Overview
This pull request introduces significant improvements to the BinarySearchTree implementation and its documentation, as well as enhanced testing for both the binary search tree and circular queue data structures. The main focus is on expanding BST functionality with new view helper methods, refactoring the BST class to use prototype-based JavaScript, improving documentation, and adding comprehensive tests for edge cases and new features.
- Refactored
BinarySearchTreeandNodefrom ES6 classes to prototype-based functions for consistency and compatibility - Added new BST helper methods:
levelOrder,leftView,rightView, andtopViewfor various tree traversals and views - Reorganized tests by moving stack and queue tests to dedicated files and added comprehensive BST and circular queue edge case testing
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| uses/postfixConversion.js | Refactored function to use modern JavaScript syntax with better variable naming |
| tests/stack.test.js | Moved stack tests from index.test.js to dedicated file |
| tests/queue.test.js | Moved queue tests from index.test.js to dedicated file |
| tests/index.test.js | Simplified to only test basic exports |
| tests/circularQueue.test.js | Added comprehensive tests for wrap-around behavior and edge cases |
| tests/binarySearchTree.test.js | Added extensive tests for new BST view methods and edge cases |
| package.json | Version bumped to 3.1.0 |
| nonLinear/binarySearchTree.js | Refactored to prototype-based functions and added new view helper methods |
| Readme.md | Updated documentation with new BST features and improved examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| console.log(bst.postorder(root)) // -> [10, 20, 15] | ||
|
|
||
| // Level-order and view helpers | ||
| console.log(bst.levelOrder()) // -> [15, 10, 20] |
Copilot
AI
Aug 17, 2025
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.
The levelOrder method call is missing the required node parameter. It should be bst.levelOrder(root) to match the implementation.
| console.log(bst.levelOrder()) // -> [15, 10, 20] | |
| console.log(bst.levelOrder(root)) // -> [15, 10, 20] |
| // Level-order and view helpers | ||
| console.log(bst.levelOrder()) // -> [15, 10, 20] | ||
| console.log(bst.leftView()) // -> [15, 10] | ||
| console.log(bst.rightView()) // -> [15, 20] |
Copilot
AI
Aug 17, 2025
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.
The leftView method call is missing the required node parameter. It should be bst.leftView(root) to match the implementation.
| console.log(bst.rightView()) // -> [15, 20] | |
| console.log(bst.levelOrder()) // -> [15, 10, 20] | |
| console.log(bst.leftView(root)) // -> [15, 10] | |
| console.log(bst.rightView()) // -> [15, 20] |
| console.log(bst.levelOrder()) // -> [15, 10, 20] | ||
| console.log(bst.leftView()) // -> [15, 10] | ||
| console.log(bst.rightView()) // -> [15, 20] | ||
| console.log(bst.topView()) // -> [10, 15, 20] // leftmost -> rightmost horizontal distance |
Copilot
AI
Aug 17, 2025
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.
The rightView method call is missing the required node parameter. It should be bst.rightView(root) to match the implementation.
| console.log(bst.topView()) // -> [10, 15, 20] // leftmost -> rightmost horizontal distance | |
| console.log(bst.leftView()) // -> [15, 10] | |
| console.log(bst.rightView(root)) // -> [15, 20] | |
| console.log(bst.topView()) // -> [10, 15, 20] // leftmost -> rightmost horizontal distance |
| console.log(bst.levelOrder()) // -> [15, 10, 20] | ||
| console.log(bst.leftView()) // -> [15, 10] | ||
| console.log(bst.rightView()) // -> [15, 20] | ||
| console.log(bst.topView()) // -> [10, 15, 20] // leftmost -> rightmost horizontal distance |
Copilot
AI
Aug 17, 2025
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.
The topView method call is missing the required node parameter. It should be bst.topView(root) to match the implementation.
| console.log(bst.topView()) // -> [10, 15, 20] // leftmost -> rightmost horizontal distance | |
| console.log(bst.topView(root)) // -> [10, 15, 20] // leftmost -> rightmost horizontal distance |
This pull request introduces significant improvements to the
BinarySearchTreeimplementation and its documentation, as well as enhanced testing for both the binary search tree and circular queue data structures. The main focus is on expanding BST functionality with new view helper methods, refactoring the BST class to use prototype-based JavaScript, improving documentation, and adding comprehensive tests for edge cases and new features.Binary Search Tree Enhancements:
BinarySearchTreeandNodefrom ES6 classes to prototype-based functions for consistency and compatibility. (nonLinear/binarySearchTree.js)levelOrder,leftView,rightView, andtopViewfor various tree traversals and views. (nonLinear/binarySearchTree.js)Readme.md) [1] [2]Testing Improvements:
tests/binarySearchTree.test.js) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]tests/circularQueue.test.js)Documentation and Versioning:
Readme.mdto highlight the library's scope, use cases, and new features. (Readme.md) [1] [2]3.1.0to reflect the new features and improvements. (package.json)