OrlandoIsay's blog

By OrlandoIsay, 10 years ago, In English

Hi everyone. Which do you think that is the best way to implement a binary tree: -Array -Vector -With pointers

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

»
10 years ago, # |
  Vote: I like it +1 Vote: I do not like it

I always use pointers.

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

    I always try to avoid them. Some teachers said me that the pointers are slower than arrays because pointers use dynamic memory. Is that true?

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

      It is. But they are quick enough (imho) in the majority of tasks. Moreover, there's a way of making pointers a lot faster: just allocate a big static array, and use this memory when you need to create a new node.

»
10 years ago, # |
  Vote: I like it +8 Vote: I do not like it

In my opinion,

  • AVL: array
  • Splay tree: pointer
»
10 years ago, # |
  Vote: I like it +42 Vote: I do not like it

std::set