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