MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / find

Method find

src/class153/FollowUp1.java:93–106  ·  view source on GitHub ↗
(int rank)

Source from the content-addressed store, hash-verified

91 // 为什么该方法不进行提根操作?
92 // 因为remove方法使用该方法时,要求find不能提根!
93 public static int find(int rank) {
94 int i = head;
95 while (i != 0) {
96 if (size[left[i]] + 1 == rank) {
97 return i;
98 } else if (size[left[i]] >= rank) {
99 i = left[i];
100 } else {
101 rank -= size[left[i]] + 1;
102 i = right[i];
103 }
104 }
105 return 0;
106 }
107
108 public static void add(int num) {
109 key[++cnt] = num;

Callers 2

indexMethod · 0.95
removeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected