I need to return an array of nodes sorted from high to low. At the moment I am trying to implement an inorder traversal which gives me the exact opposite of what I’m looking for. The tree looks like: My function looks like: From this, I receive: When I need to receive: Is there a way that I can reverse
Tag: binary-search-tree
Can I do a binary search on an array of objects?
I am currently learning how to use searching and sorting algorithms and I am running into issues with a binary search on an array of objects of customers’ data. The array of customers is sorted by first and last name. The goal is to find a customer’s email and return the index. The data looks like: My binary search function
Recursive Add method for BST using Javascript not working
Below is the implementation of a BST with an insertion function for it. currently, the code wouldn’t work; It would just spit out Tree { root: null } When i tried to debug it, it seems that it successfully adds the new Node to the correct spot, but once it returns from the function, all that data is lost and
Checking if a Binary Search Tree is Valid javascript
I came across this problem online and I found the following function to check if a BST is valid. However, what I don’t fully understand is how max/min change from null to values that you can compare against. so in the following function: when you come back up from the lowest depth on the left it compares the value at