mridul1809's blog

By mridul1809, history, 5 years ago, In English

Hey everyone!

For last couple of days I have been working on creating a class for Trie data structure. This class provides few necessary and standard functions out of the box!

Here it is : Link

Also , I have added support for creating Persistent Trie. (You can learn about it over here)

You can see in this submission how easy it is to use this class for solving questions on persistent trie!

I invite all of you to use this template , suggest changes/improvements , point out errors, anything you think should be enhanced or added!

You can contact via commenting , DM or even raise a pull request and be a contributor!

Looking forward to your responses! :D

Thank you! :)

PS : Watch the github repository to know about future additions. Star if you like my work! :D

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Thanks, I was looking for something without pointers. Is it possible for most persistence problems to solve them without pointers?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Yup it definitely is! Instead of using malloc , just make a vector from where all your allocations take place, and instead of storing a pointer , store index for that element!

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      You can add 'deletion' operation?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        Yup why not! will work on that :D Thanks for suggestion!

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
          Rev. 2   Vote: I like it +3 Vote: I do not like it

          Your code is giving compile error. After declaring int freq inside struct TrieNode it works.

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Resolved!So sorry for the inconvenience! Thanks for pointing it out! :D

            • »
              »
              »
              »
              »
              »
              »
              5 years ago, # ^ |
              Rev. 2   Vote: I like it 0 Vote: I do not like it

              There is also an issue with printing correct frequencies. Maybe because they are not intialized. Edit — Now I think it's correct.

              • »
                »
                »
                »
                »
                »
                »
                »
                5 years ago, # ^ |
                Rev. 2   Vote: I like it 0 Vote: I do not like it

                I have not yet tested the code to work on frequencies! :( maybe you can recommend me some question relating to frequency where i can test this template?

                EDIT : tested!

»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

revolutionary