Skip to content

Commit e85d379

Browse files
committed
add splay_tree.md file
1 parent a60d4dc commit e85d379

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/src/splay_tree.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
```@meta
2+
DocTestSetup = :(using DataStructures)
3+
```
4+
5+
# Splay Tree
6+
7+
The `SplayTree` type is an implementation of Splay Tree in Julia. It is a self-balancing binary search tree with the additional property that recently accessed elements are quick to access again. Operations such as search, insert and delete can be done in `O(log n)` amortized time, where `n` is the number of nodes in the `SplayTree`.
8+
9+
Examples:
10+
11+
```jldoctest
12+
julia> tree = SplayTree{Int}();
13+
14+
julia> for k in 1:2:20
15+
push!(tree, k)
16+
end
17+
18+
julia> haskey(tree, 3)
19+
true
20+
21+
julia> tree[4]
22+
7
23+
24+
julia> for k in 1:2:10
25+
delete!(tree, k)
26+
end
27+
28+
julia> haskey(tree, 5)
29+
false
30+
```
31+
32+
```@meta
33+
DocTestSetup = nothing
34+
```

0 commit comments

Comments
 (0)