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

Автор GreyMaster, история, 8 лет назад, По-английски

Hello.

I need a little help about set data structure. Is it possible that access the i-th element of a set with O(1) ?

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

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

First of all, you cannot access an element of a std::set with less complexity than O(log(n)). And also you cannot access the i-th element of a set. But you can do this with a little trick.

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

    Thank you. But I know before that it is possible to accsess the i-th element with O(n) .So is there no work to acsess the i-th element with O(log n)?

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

      unfortunately no. I don't know why they didn't make this feature although it was easy to be done