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) ?
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) ?
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | heuristica | 3322 |
| 10 | maroonrk | 3312 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 144 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | BledDest | 133 |
| 9 | maroonrk | 132 |
| 10 | Proof_by_QED | 131 |
| Name |
|---|



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.
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)?
unfortunately no. I don't know why they didn't make this feature although it was easy to be done