Is there any data structure that would provide O (1) - that is, a constant - input complexity and search complexity (log (n)) even in the worst case ?
A sorted vector can do an O (log (n)) search, but the insert will take O (n) (given that I don't always insert elements either in front or back). While the list will do O (1), it will not be able to provide O (log (n)) searches.
I wonder if such a data structure can be implemented.
Yes, but you have to bend the rules a bit in two ways:
1) , O (1) O (1) (, CritBit , ) , O (log n).
. , (, 32 ) , , ('0') ('1') node. - O (32), O (1).
2) , O (1) , O (1) , (, 32- 64-), .
, O (log n), . , 16- , , 2 ^ 16 = 65563.
, .
OK, NOT
, , B, Red-black tree AVL, O(log N), , O(log N). , ( ) , .
O(log N)
, NOT
, , O(1), LL O(N), , .
O(1)
O(N)
Skiplist, , O(log N) ( , O(1)).
Hashmap , , O(N) .
( , , , , ; , ).
, c . (Heck, , n c * n .) , n , . , Omega (n), , , . , . Omega (n).
- . : , . . , , . . , , , - , . - -, ( -, - -). , n/2 2 * c , n/2/3 ^ (2 * c) = Omega (n). , .
Source: https://habr.com/ru/post/1659924/More articles:FIND_IN_SET () function does not work in codeigniter - codeigniterCopying data between different databases (both supported by jdbc) - javaUbuntu, can't start reacting-native: could not find tools.jar - androidПочему точка с запятой не может быть вставлена через атрибут стиля javascript? - javascriptCan you run Google cloud functions through a firebase event without a server? - firebasePermission denied: opening provider com.google.android.apps.photos.contentprovider.MediaContentProvider, which is not exported from uid - androidCustom deserialization using Json.NET - json.NET Core publication error: "Could not find msdeploy.exe, install it and try again" - windowsWhat is the difference between rxjava2 Maybe and Optional? - javaBatch error "+ unexpected" - batch-fileAll Articles