Trie saves space, but how?

前端 未结 5 925
离开以前
离开以前 2021-02-07 13:05

I am confused as to how the Trie implementation saves space & stores data in most compact form!

If you look at the tree below. When you store a character at any nod

5条回答
  •  面向向阳花
    2021-02-07 13:41

    It's not about cheap space in memory, it's about precious space in a file or on a communications link. With an algorithm that builds that trie, we can send 'ten' in three bits, left-right-right. Compared to the 24 bits 'ten' would take up uncompressed, that's a huge savings of valuable disk space or transfer bandwidth.

提交回复
热议问题