I need a collection data structure that can do the following:
My thoughts at this stage are that I need a priority queue and a hash table, although I don’t know if I can quickly set values at both ends of the priority queue. Another possibility is to simply support the OrderedDictionary and sort the insert each time I add more data to it.
Since I'm interested in performance for a moderate number of elements (I would rate less than 200,000), I'm not sure what asymptotic performance I require for these operations. n will not grow indefinitely, so low constant productivity kin k * O(n)can be just as important O(n). However, I would prefer that both inserts and pop operations take O(log n)time.
k
k * O(n)
O(n)
O(log n)
Also, are there any specific implementations in Python? I really would like to avoid writing this code myself.
You can get good performance for these operations using blisteither a database (e.g. sqlite , which is located in stdlib).
blist
I suggest some kind of balanced binary tree such as red-black tree.
A search in PyPi generates several implementations. A google search will give you more.
bintrees PyPi Python, C/Cython. , emptor.
- , (, , ) - O (log2 (N)), 200 000 17-18 .
. , O (log n).
Python, :
http://infohost.nmt.edu/tcc/help/lang/python/examples/pyskip/
, , , ?
node, node ( " " ).
, ( min/max), / O (log n).
(// , -/, // ) O (logn) , .
, , python AVL ( ), : http://www.python.org/ftp/python/contrib-09-Dec-1999/DataStructures/avl.README
, .
, , , - , .
, , O (1) min, max ( deleteMin deleteMax O (log (N))). , - Python, , .
, , :
http://www.mhhe.com/engcs/compsci/sahni/enrich/c9/interval.pdf
O (log n) pop, dequeue insert, , - , , .
, , , , (1) (2) pop dequeue, , , . . , , , corr. .
-, min-max heap (. ), " ", , , . , O (n) .
min-max , min max O (1) , O (log (n)) min max, , .
Java, TreeSet NavigableSet.
It is implemented as a Red-Black-Tree.
Source: https://habr.com/ru/post/1745545/More articles:Release Management Using a Distributed Version Management System - dvcsWhat is the most efficient way to find missing semicolons in VS with C ++? - c ++ideas for simple objects for everyday use by web developers? - oophttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1745543/index.html&usg=ALkJrhjUKyWZrpKg8ZEYbHGkpNTMNjbAqAFind and copy regex in bash (saving folder structure)? - bashPHP Uploadprogress extension function always returns null, no download data - phpПеременная Количество полей ввода в формате Classic-ASP - asp-classichttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1745548/index.html&usg=ALkJrhgA52C8tcKIlJvGl6AsFEvxiOvEFQhow to use new image folder in cakephp - cakephpalt-tab web design view - htmlAll Articles