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
Tag: data-structures
How to keep an Javascript object/array ordered while also maintaining key lookups?
I have some data which I originally stored in a generic Javascript object, with the ID as a key: However, I discovered that browsers do not guarantee a particular object order when looping through them, so in the above “3” would come before “7”. I switched to using an array format like this: Now, I can loop in the correct
Set of objects in javascript
I’d like to have a set of objects in Javascript. That is, a data structure that contains only unique objects. Normally using properties is recommended, e.g. myset[“key”] = true. However, I need the keys to be objects. I’ve read that Javascript casts property names to strings, so I guess I can’t use myset[myobject] = true. I could use an array,