FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms/src/main/java/com/set/BSTSet.java at master · verifyCode/algorithms · GitHub
verifyCode
algorithms
Repository navigation
Code
Issues
Pull requests
2
(2)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms
/
src
/
main
/
java
/
com
/
set
/
BSTSet.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (50 loc) · 1.01 KB
Breadcrumbs
algorithms
/
src
/
main
/
java
/
com
/
set
/
BSTSet.java
Copy path
File metadata and controls
58 lines (50 loc) · 1.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package
com
.
set
;
import
com
.
tree
.
bst
.
BST
;
/**
* 基于二分搜索树
*
* @author xjn
* @since 2019-12-25
*/
public
class
BSTSet
<
E
extends
Comparable
<
E
>>
implements
MySet
<
E
> {
private
BST
<
E
>
bst
;
public
BSTSet
() {
bst
=
new
BST
<>();
}
//O(h) h:二分搜索树的高度
// 0层1个节点
// 1层2个节点
// 2层4个节点
// 3层8个节点
// 4层16个节点
// h层2^(h-1)个节点
// h层全部多少节点 = 2^h - 1
// n = 2^h -1
// h = log2(n + 1)
//O(h) = O(log n)
@
Override
public
void
add
(
E
e
) {
bst
.
add
(
e
);
}
//O(h) h:二分搜索树的高度
//O(h) = O(log2)
@
Override
public
void
remove
(
E
e
) {
bst
.
remove
(
e
);
}
//O(h) = O(log2)
@
Override
public
boolean
contains
(
E
e
) {
return
bst
.
contains
(
e
);
}
//O(1)
@
Override
public
int
getSize
() {
return
bst
.
getSize
();
}
//O(1)
@
Override
public
boolean
isEmpty
() {
return
bst
.
isEmpty
();
}
}
Back
|
FazBrowse Home
|
New Git URL