Изменения

Перейти к: навигация, поиск

Обзор поисковых структур данных

16 170 байт добавлено, 14:41, 10 мая 2015
Новая страница: «'''Поисковая структура данных''' - любая структура данных реализующая эффективный поиск к...»
'''Поисковая структура данных''' - любая структура данных реализующая эффективный поиск конкретных элементов множества, например, конкретной записи в базе данных.

Простейший, наиболее общий, но менее эффективный поисковой структурой является простая неупорядоченный последовательная всех элементов. Расположив элементы в такой список, неизбежно возникнет ряд операций, которые потребуют линейного времени, в худшем случае, а также в средней случае. Используемные в реальной жизни поисковые структуры данных позволяют совершать операции более быстро, однако они ограничены запросами некоторого конкретного вида. Кроме того, поскольку стоимость построение таких структур, по крайней мере пропорционально n, они окупятся, даже если поступает лишь несколько запросов.

'''Статические''' поисковые структуры данных предназначены для ответа на запросы на фиксированной базе данных; '''Динамические''' поиковые структуры также позволяют вставки, удаления или модификации элементов между последовательными запросами. В динамическом случае, необходимо также учитывать стоимость изменения структуры данных.

=== Время работы ===

Эту классификацию обычно считают самой важной. Оценивают худшее время алгоритма, среднее и лучшее для каждой операции. Лучшее время — минимальное время работы алгоритма на каком-либо наборе. Худшее время — наибольшее время.

=== Используемая память ===

Параметр структуры данных, показывающий, сколько памяти ей требуется. Обычно затраты состовляют <tex>O(n)</tex>.

=== Сравнение структур данных ===

Сравненим эффиктивность посиковых структур данных для реализации интерфейса [[Упорядоченное множество|упорядочего множества]].

{| class="wikitable"
|-
! rowspan="2" |
! colspan="2" | Insert
! colspan="2" | Delete
! colspan="2" | Search
! colspan="2" | Minimum
! colspan="2" | Maximum
! colspan="2" | Predecessor
! colspan="2" | Successor
! colspan="2" | Память
|-
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
! Сре-<br>днее
! Худ-<br>шее
|-
| Неотсортированный<br>массив
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
| Отсортированный<br>массив
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
| Неотсортированный<br>[[Список|список]]
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
| Отсортированный<br>[[Список|список]]
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
| [[Дерево поиска, наивная реализация|Дерево поиска,<br>наивная<br> реализация]]
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[АВЛ-дерево]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[2-3 дерево]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[B-дерево]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[Красно-черное дерево|Красно-черное<br>дерево]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
| [[Декартово дерево]]
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[Splay-дерево]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[Tango-дерево]]
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(\log \log n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[Дерево ван Эмде Боаса|Дерево<br>ван Эмде Боаса]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log k)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log k)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log k)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log k)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log k)</tex>
| colspan="2" align="center" style="background: #ffdddd;" | <tex>O(2^k)</tex>
|-
| [[Список с пропусками|Список с<br>пропусками]]
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| colspan="2" align="center" style="background: #ddffdd;" | <tex>O(1)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(n \log n)</tex>
|-
|[[Fusion tree]]
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(\log_{w} n)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|-
|[[Сверхбыстрый цифровой бор|Сверхбыстрый<br> цифровой бор]]
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| align="center" style="background: #ffffdd;" | <tex>O(\log w)</tex>
| align="center" style="background: #ffdddd;" | <tex>O(w)</tex>
| colspan="2" align="center" style="background: #ffffdd;" | <tex>O(n)</tex>
|}
55
правок

Навигация