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

@@ -596,12 +596,6 @@ comments: true
throw new EmptyStackException();
return nums[front];
}
/* 访问指定索引元素 */
int get(int index) {
if (index >= size())
throw new IndexOutOfBoundsException();
return nums[(front + index) % capacity()];
}
}
```
@@ -659,12 +653,6 @@ comments: true
throw out_of_range("队列为空");
return nums[front];
}
/* 访问指定位置元素 */
int get(int index) {
if (index >= size())
throw out_of_range("索引越界");
return nums[(front + index) % capacity()]
}
};
```
@@ -715,13 +703,6 @@ comments: true
return False
return self.__nums[self.__front]
""" 访问指定位置元素 """
def get(self, index):
if index >= self.size():
print("索引越界")
return False
return self.__nums[(self.__front + index) % self.capacity()]
""" 返回列表用于打印 """
def to_list(self):
res = [0] * self.size()
@@ -837,12 +818,6 @@ comments: true
throw new Error("队列为空");
return this.#queue[this.#front];
}
/* 访问指定索引元素 */
get(index) {
if (index >= this.size)
throw new Error("索引越界");
return this.#queue[(this.#front + index) % this.capacity];
}
}
```
@@ -893,12 +868,6 @@ comments: true
throw new Error("队列为空");
return this.queue[this.front];
}
/* 访问指定索引元素 */
get(index: number): number {
if (index >= this.size)
throw new Error("索引越界");
return this.queue[(this.front + index) % this.capacity];
}
}
```

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];
}
};
```