DCSekhara's blog

By DCSekhara, history, 4 years ago, In English

Recently I came across this blog Efficient and Easy segment trees. After reading this I felt that the normal implementation with 5 arguments is easier to understand and implement(in my opinion). I want to know which of the implementations of segment-tree is better so that if the one written in the blog is better I will try to learn it. (better in the sense that it can be easily be applied in some new question)

  • Vote: I like it
  • -19
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by DCSekhara (previous revision, new revision, compare).

»
4 years ago, # |
Rev. 3   Vote: I like it +3 Vote: I do not like it

There isn't a "perfect" implementation of a Segment Tree. It's all based on what you prefer and are comfortable with. I prefer recursive Segment Trees over iterative because while iterative Segment Trees are shorter to code, recursive ones are easier to understand and modify at least for me.
If I was looking for an implementation I could easily modify and adapt to solve new different questions, personally I would use the recursive implementation.

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

    thanks. I too personally feel the same. But since the blog is written by a red-coder I doubted myself