Update Q&A of data_structure, array_and_linkedlist (#861)

* "Add Q&A sections to array/linked_list and tree chapters"

Added question and answers related to the use of std::list in C++ and space complexity in full binary tree traversal to their respective chapters in array_and_linked_list and tree documentation.

* Update summary.md

* Update summary.md

* Update summary.md

* "Expand details on HashTable, arrays, and linked lists in docs"

Extended the section explaining how HashTables use both linear and nonlinear data structures. Added Q&A sections addressing common questions on character type size, the static and dynamic nature of array-based data structures, and distinguishing array and linked list from logic and physical perspective. These changes provide clearer understanding for readers.

* "Add FAQs to array and linked list docs chapter"

Added several Frequently Asked Questions to improve clarity in the arrays and linked list documentation chapter. These questions mainly address the behavior and structure of array initializations, circular array queues, and single-link list node deletion. Providing answers to these can enhance understanding and prevent misconceptions among readers.

* Update summary.md

* Update summary.md

* Update summary.md

---------

Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
Sizhuo Long
2023-10-23 07:54:25 +11:00
committed by GitHub
parent e81c9a85b5
commit 9562287a21
2 changed files with 19 additions and 2 deletions

View File

@@ -60,7 +60,7 @@
与许多语言不同的是,在 Python 中数字也被包装为对象,列表中存储的不是数字本身,而是对数字的引用。因此,我们会发现两个数组中的相同数字拥有同一个 id ,并且这些数字的内存地址是无须连续的。
!!! question "C++ STL 里面的 std::list 已经实现了双向链表,但好像一些算法的书上都不怎么直接用这个,是不是有什么局限性呢?"
!!! question "C++ STL 里面的 `std::list` 已经实现了双向链表,但好像一些算法的书上都不怎么直接用这个,是不是有什么局限性呢?"
一方面,我们往往更青睐使用数组实现算法,而只有在必要时才使用链表,主要有两个原因。
@@ -68,3 +68,11 @@
- 缓存不友好:由于数据不是连续存放的,`std::list` 对缓存的利用率较低。一般情况下,`std::vector` 的性能会更好。
另一方面,必要使用链表的情况主要是二叉树和图。栈和队列往往会使用编程语言提供的 `stack` 和 `queue` ,而非链表。
!!! question "初始化列表 `res = [0] * self.size()` 操作,会导致 `res` 的每个元素引用相同的地址吗?"
不会。但二维数组会有这个问题,例如初始化二维列表 `res = [[0] * self.size()]` ,则多次引用了同一个列表 `[0]` 。
!!! question "在删除节点中,需要断开该节点与其后继节点之间的引用指向吗?"
从数据结构与算法(做题)的角度看,不断开没有关系,只要保证程序的逻辑是正确的就行。从标准库的角度看,断开更加安全、逻辑更加清晰。如果不断开,假设被删除节点未被正常回收,那么它也会影响后继节点的内存回收。