Update the structure of the chapter

of binary tree.
This commit is contained in:
Yudong Jin
2022-12-21 17:19:39 +08:00
parent f3ef226874
commit f39636cb63
22 changed files with 402 additions and 572 deletions

View File

@@ -451,12 +451,6 @@ comments: true
throw new EmptyStackException();
return stack.get(size() - 1);
}
/* 访问索引 index 处元素 */
public int get(int index) {
if (index >= size())
throw new EmptyStackException();
return stack.get(index);
}
}
```
@@ -493,12 +487,6 @@ comments: true
throw out_of_range("栈为空");
return stack.back();
}
/* 访问索引 index 处元素 */
int get(int index) {
if(index >= size())
throw out_of_range("索引越界");
return stack[index];
}
};
```
@@ -531,11 +519,6 @@ comments: true
def peek(self):
assert not self.is_empty(), "栈为空"
return self.__stack[-1]
""" 访问索引 index 处元素 """
def get(self, index):
assert index < self.size(), "索引越界"
return self.__stack[index]
```
=== "Go"
@@ -617,12 +600,6 @@ comments: true
throw new Error("栈为空");
return this.stack[this.stack.length - 1];
}
/* 访问索引 index 处元素 */
get(index) {
if (index >= this.size)
throw new Error("索引越界");
return this.stack[index];
}
};
```
@@ -659,12 +636,6 @@ comments: true
throw new Error('栈为空');
return this.stack[this.stack.length - 1];
}
/* 访问索引 index 处元素 */
get(index: number): number | undefined {
if (index >= this.size)
throw new Error('索引越界');
return this.stack[index];
}
};
```