DEV Community

Discussion on: Tree Data Structures Explained with JavaScript

Collapse
 
johncip profile image
jmc • Edited

Trees are fun 🌲🌲🌲. I like your diagrams and am looking forward to the AVL post.

I had a couple of questions / notes:

I'm confused about where you said that the DOM is a binary tree, since DOM nodes can have any number of children. (Specifically you said "searching the DOM" but it seems like the same story?)

Also, in the same section, your "map" bullet links to your article saying:

HashMaps has many names like HashTable, HashMap, Map, Dictionary, Associative Arrays and so on. The concept is the same while the implementation might change slightly.

I get your meaning but tend to think of it more like:

Maps, dictionaries, and associative arrays all describe the same abstract data type. But hash map implementations are distinct from tree map implementations in that one uses a hash table and one uses a search tree. (With the differences in sort order and time complexity that those two imply.)

In other words, when I read "hash map," I think "implemented using a hash table." My attitude may be overly influenced by the Java standard library, but it seems like a fair assumption, and I can't find any counterexamples at the moment.

Collapse
 
amejiarosario profile image
Adrian Mejia • Edited

Thanks, John, for your comments.

Agree that the DOM is not a binary tree, but a tree. I doubled check the intro, and it looks correct. However, I listed the tree applications in the wrong place. It should be outside the binary tree section. Thanks for pointing that out, I'll fix it.

About the Hashmap article, that's right. I could have been more descriptive. I'll make the change. BTW, I implemented HashMaps and also TreeMaps in JavaScript with a similar interface used in the Java standard API. It's not covered on the posts but is on the DSA.js book and github repo: github.com/amejiarosario/dsa.js/bl...

About the AVL tree post you can find it in my blog already or wait for next week when I publish it here ;)