chapter_array_and_linkedlist/summary/ #150
Replies: 44 comments 38 replies
-
对 Cache locality 的一个简单解释:Why does cache locality matter for array performance? |
Beta Was this translation helpful? Give feedback.
-
"列表的出现大大提升了数组的实用性,但副作用是会造成部分内存空间浪费",这里的”部分内存空间浪费“是指额外增加的变量如容量、长度、扩容倍数所占的内存吗? |
Beta Was this translation helpful? Give feedback.
-
Q&A看得我云里雾里,不过小结的总结很简练。局部缓存的知识感觉很及时 |
Beta Was this translation helpful? Give feedback.
-
Q&A的最后一条的解释可能不是很完美。在Python中分代码块,如果在同一个代码块里面,则采用统一代码块下的缓存机制。如果属于不同的代码块,则采用小数据池的缓存机制(可以理解成单例的或者全局的字典),而且对于int类型来说,小数据池的缓存范围在-5到256 |
Beta Was this translation helpful? Give feedback.
-
JavaScript中数组没有要求一定要是一样的类型吧?目前在学java感觉两科语言差异还是有蛮多的 |
Beta Was this translation helpful? Give feedback.
-
Hi, K神, |
Beta Was this translation helpful? Give feedback.
-
关于Q&A第一条有些不懂的地方 |
Beta Was this translation helpful? Give feedback.
-
关于Q&A中 在 Python 中初始化 n = [1, 2, 3] 与初始化 m = [2, 1, 3] |
Beta Was this translation helpful? Give feedback.
-
DAY3 |
Beta Was this translation helpful? Give feedback.
-
python中的列表是本文提到的动态数组吗。列表允许存储不同类型的元素,但数组要求相同类型的元素 |
Beta Was this translation helpful? Give feedback.
-
例如,双向队列适合使用链表实现,我们维护一个指针变量始终指向头结点、尾结点,每次插入与删除操作都是 O(1)。 |
Beta Was this translation helpful? Give feedback.
-
对于“初始化列表 res = [0] * self.size() 操作,会导致 res 的每个元素引用相同的地址吗?”这个问题。在python中,正如您之前讲到的列表中每个数字都是一个引用,那您回答中的“初始化二维列表 res = [[0] * self.size()] 多次引用了同一个列表 [0]”是如何发现的呢? |
Beta Was this translation helpful? Give feedback.
-
想问一下:有没有推荐的相应的题目可以用来巩固和拓展的呀 |
Beta Was this translation helpful? Give feedback.
-
对于 “ 初始化列表 res = [0] * self.size() 操作,会导致 res 的每个元素引用相同的地址吗?” 这个问题,运行下面的代码得到每个对象的 id 地址值是同样的,那为什么答案是 "不会引用相同的地址" 呢? res = [0] * 5
for r in res:
print(id(r)) |
Beta Was this translation helpful? Give feedback.
-
two day. |
Beta Was this translation helpful? Give feedback.
-
Q:操作 res = [[0]] * n 生成了一个二维列表,其中每一个 [0] 都是独立的吗? res = [[0]] * 3 # [[0], [0], [0]]
res[0][0] = 1 # [[1], [1], [1]]
res = [[0] * 3] # [[0], [0], [0]]
res[0]= [1] # [[1], [0], [0]] |
Beta Was this translation helpful? Give feedback.
-
“Python 中的数字也被包装为对象,列表中存储的不是数字本身,而是对数字的引用” 长见识了 |
Beta Was this translation helpful? Give feedback.
-
好家伙,python里面变量存储的都是对象的引用,涨知识了,那是不是所有弱类型语言的实现都是和python一样? |
Beta Was this translation helpful? Give feedback.
-
day03 |
Beta Was this translation helpful? Give feedback.
-
在该列表中,所有整数 0 都是同一个对象的引用。这是因为 Python 对小整数(通常是 -5 到 256)采用了缓存池机制,以便最大化对象复用,从而提升性能。 虽然它们指向同一个对象,但我们仍然可以独立修改列表中的每个元素,这是因为 Python 的整数是“不可变对象”。当我们修改某个元素时,实际上是切换为另一个对象的引用,而不是改变原有对象本身。 然而,当列表元素是“可变对象”时(例如列表、字典或类实例等),修改某个元素会直接改变该对象本身,所有引用该对象的元素都会产生相同变化。 |
Beta Was this translation helpful? Give feedback.
-
打卡2025/6/8太精彩了! |
Beta Was this translation helpful? Give feedback.
-
你的邮件我已经收到!
|
Beta Was this translation helpful? Give feedback.
-
2025年6月12日 |
Beta Was this translation helpful? Give feedback.
-
打卡 2025/7/7好困 |
Beta Was this translation helpful? Give feedback.
-
你的邮件我已经收到!
|
Beta Was this translation helpful? Give feedback.
-
坚持学习,打卡20250805 |
Beta Was this translation helpful? Give feedback.
-
你的邮件我已经收到!
|
Beta Was this translation helpful? Give feedback.
-
在Java中,ArrayList 和 LinkedList 都是 Java 中 List 接口的实现类,ArrayList 基于动态数组,LinkedList 基于双向链表。 |
Beta Was this translation helpful? Give feedback.
-
你的邮件我已经收到!
|
Beta Was this translation helpful? Give feedback.
-
有点不是很理解列表和链表直接的区别,希望有友友可以帮忙解答,感谢 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
chapter_array_and_linkedlist/summary/
一本动画图解、能运行、可提问的数据结构与算法入门书
https://www.hello-algo.com/chapter_array_and_linkedlist/summary/
Beta Was this translation helpful? Give feedback.
All reactions