fix: Several code bug fixes (#973)

* Update counting_sort.c and quick_sort.c

* Code bug fixes.
This commit is contained in:
Yudong Jin
2023-11-29 23:14:55 +08:00
committed by GitHub
parent 56b20eff36
commit b824d149cb
4 changed files with 4 additions and 6 deletions
@@ -51,7 +51,7 @@ func (m *hashMapOpenAddressing) get(key int) string {
// 线性探测,从 index 开始向后遍历
for i := 0; i < m.capacity; i++ {
// 计算桶索引,越过尾部返回头部
j := (idx + 1) % m.capacity
j := (idx + i) % m.capacity
// 若遇到空桶,说明无此 key ,则返回 null
if m.buckets[j] == (pair{}) {
return ""
@@ -99,7 +99,7 @@ func (m *hashMapOpenAddressing) remove(key int) {
// 线性探测,从 index 开始向后遍历
for i := 0; i < m.capacity; i++ {
// 计算桶索引,越过尾部返回头部
j := (idx + 1) % m.capacity
j := (idx + i) % m.capacity
// 若遇到空桶,说明无此 key ,则直接返回
if m.buckets[j] == (pair{}) {
return