chapter_array_and_linkedlist/array/ #84
Replies: 86 comments 120 replies
-
缓存局部性:简单的说是和命中率有关系,分时间局部性和空间局部性 |
Beta Was this translation helpful? Give feedback.
-
很不错,数组的插入和删除理解的重点是在索引 |
Beta Was this translation helpful? Give feedback.
-
删除索引 index 元素时,可在代码中,循环结束后,将 nums 最后位置元素重置为 0,nums[-1] = 0, 使之与图片中的末尾元素无意义概念一致。 另外,插入元素时,Python 代码中,索引是否正确? 我的理解: for i in range(len(nums) - 1, index +1, -1). |
Beta Was this translation helpful? Give feedback.
-
已fork,正着手编写数组的Go示例 |
Beta Was this translation helpful? Give feedback.
-
数组中首个元素对应数组的内存地址偏移量是0,所以数组索引从0开始算起,学到了,感谢!!! |
Beta Was this translation helpful? Give feedback.
-
/* 初始化数组 */ |
Beta Was this translation helpful? Give feedback.
-
数组遍历 C++ 代码示例,只是 count++,没有遍历数组,是不是本来要写成 count += nums[i]? |
Beta Was this translation helpful? Give feedback.
-
代码示例 应该加一下语言的语法糖写法? 比如 rust 很多情况是不用 for的 根据情况编译后的效率也比for循环高效 虽然有些矛盾。 但是我觉得可以列出两种实现方式, 一个是for 理解原理另一个是如何更简便的写法。 |
Beta Was this translation helpful? Give feedback.
-
这个网站怎么没有记录功能,是因为没有后端用户服务器吗,, |
Beta Was this translation helpful? Give feedback.
-
作者您好,为什么在这里会强调“相同类型的元素”,而在下一章链表中却没有强调同类型呢? |
Beta Was this translation helpful? Give feedback.
-
之前都是在用,没有看到这么底层 |
Beta Was this translation helpful? Give feedback.
-
“数组有多种初始化写法。根据实际需要,选代码最短的那一种就好。” k神,个人感觉这句话有点奇怪, |
Beta Was this translation helpful? Give feedback.
-
请问计算内存地址那里为什么元素长度为4呢?我看数组长度为5,为什么不是5呢 |
Beta Was this translation helpful? Give feedback.
-
您好还是不太理解c++数组删除那块,我知道有效长度-1之后最末尾的元素可以忽略掉(无意义),可是这在源代码中没有体现,请问这该如何实现呀?第二个问题是在插入的时候不应该先判断是否满数组再扩容吗?感谢解答 |
Beta Was this translation helpful? Give feedback.
-
Hello! K大,想问下您的图都是怎么画的啊,感觉也太整齐美观了,想学习一下 |
Beta Was this translation helpful? Give feedback.
-
缓存局部性,死去的计组知识开始复活。 |
Beta Was this translation helpful? Give feedback.
-
def traverse(nums: list[int]):
"""遍历数组"""
count = 0
# 通过索引遍历数组
for i in range(len(nums)):
count += nums[i]
# 直接遍历数组元素
for num in nums:
count += num
# 同时遍历数据索引和元素
for i, num in enumerate(nums):
count += nums[i]
count += num 为什么不用两个变量区分次数求和和元素求和,演示的count应该分段清零 |
Beta Was this translation helpful? Give feedback.
-
写的很清晰哦,点赞 |
Beta Was this translation helpful? Give feedback.
-
关于删除元素有些不理解,末尾元素无意义但是仍然是客观存在的,如果要做遍历之类的操作依然逃不开这个无意义的元素,还是说在届时会记录一个有效长度来规避这个问题? |
Beta Was this translation helpful? Give feedback.
-
不懂就问: int *res = new int[size + enlarge]。 res 是一个地址指针 ,为什么可以res[i] 这样像数组一样来使用res。 res只是获得了新建数组的首地址,就有了数组的功能了吗? |
Beta Was this translation helpful? Give feedback.
-
呼唤大神: int *extend (int *nums, int size, int enlarge) 里面参数 int * nums 可以改成 int nums[]吗? 这有什么不同? |
Beta Was this translation helpful? Give feedback.
-
random_index = random.randint(0, len(nums) - 1) 这行代码生成成的随机数终止值为什么要减去1 |
Beta Was this translation helpful? Give feedback.
-
这应该是列表... import array |
Beta Was this translation helpful? Give feedback.
-
array.py是不是有一点问题,插入之后会丢失原数组中最后一个元素 |
Beta Was this translation helpful? Give feedback.
-
想问一下各位前端的小伙伴们,用js学习这个算法合适嘛,我怎么感觉看起来有点怪怪的呢 |
Beta Was this translation helpful? Give feedback.
-
大佬,扩容数组那里的Java代码不知道是不是有问题 int[] extend(int[] nums, int enlarge) {
} 以上这一段,方法名定义为 |
Beta Was this translation helpful? Give feedback.
-
Pad看不了可视化 |
Beta Was this translation helpful? Give feedback.
-
那个遍历数组错了吧,,,我输出的是累加和 |
Beta Was this translation helpful? Give feedback.
-
我想问一下对于一个初一的学生,二维数组是否可以理解为平面直角坐标系中的格点?下标对应坐标? |
Beta Was this translation helpful? Give feedback.
-
我想问一下对于一个初一的学生,二维数组是否可以理解为平面直角坐标系中的格点?下标对应坐标? |
Beta Was this translation helpful? Give feedback.
-
chapter_array_and_linkedlist/array/
动画图解、一键运行的数据结构与算法教程
https://www.hello-algo.com/chapter_array_and_linkedlist/array/
Beta Was this translation helpful? Give feedback.
All reactions