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

@ -45,13 +45,6 @@ class ArrayStack {
return stack.get(size() - 1);
}
/* 访问索引 index 处元素 */
public int get(int index) {
if (index >= size())
throw new IndexOutOfBoundsException();
return stack.get(index);
}
/* 将 List 转化为 Array 并返回 */
public Object[] toArray() {
return stack.toArray();
@ -75,10 +68,6 @@ public class array_stack {
int peek = stack.peek();
System.out.println("栈顶元素 peek = " + peek);
/* 访问索引 index 处元素 */
int num = stack.get(3);
System.out.println("栈索引 3 处的元素为 num = " + num);
/* 元素出栈 */
int pop = stack.pop();
System.out.println("出栈元素 pop = " + pop + ",出栈后 stack = " + Arrays.toString(stack.toArray()));