Блог пользователя OrlandoIsay

Автор OrlandoIsay, 9 лет назад, По-английски

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

  • Проголосовать: нравится
  • +23
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

I always use pointers.

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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?

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      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.

»
9 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

In my opinion,

  • AVL: array
  • Splay tree: pointer
»
9 лет назад, # |
  Проголосовать: нравится +42 Проголосовать: не нравится

std::set