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

@@ -17,8 +17,17 @@
!!! question "为什么哈希表同时包含线性数据结构和非线性数据结构?"
哈希表底层是数组,而为了解决哈希冲突,我们可能会使用“链式地址”(后续哈希表章节会讲)。在拉链法中,数组中每个地址(桶)指向一个链表;当这个链表长度超过一定阈值时,又可能被转化为树(通常为红黑树)。因此,哈希表可能同时包含线性(数组、链表)和非线性(树)数据结构。
哈希表底层是数组,而为了解决哈希冲突,我们可能会使用“链式地址”(后续哈希表章节会讲):数组中每个桶指向一个链表,当链表长度超过一定阈值时,又可能被转化为树(通常为红黑树)。
从存储的角度来看,哈希表的底层是数组,其中每一个桶槽位可能包含一个值,也可能包含一个链表或树。因此,哈希表可能同时包含线性(数组、链表)和非线性(树)数据结构。
!!! question "`char` 类型的长度是 1 byte 吗?"
`char` 类型的长度由编程语言采用的编码方法决定。例如Java、JS、TS、C# 都采用 UTF-16 编码(保存 Unicode 码点),因此 char 类型的长度为 2 bytes 。
!!! question "基于数组实现的数据结构也被称为“静态数据结构” 是否有歧义?因为栈也可以进行出栈和入栈等操作,这些操作都是“动态”的。"
栈确实可以实现动态的数据操作,但数据结构仍然是“静态”(长度不可变)的。尽管基于数组的数据结构可以动态地添加或删除元素,但它们的容量是固定的。如果数据量超出了预分配的大小,就需要创建一个新的更大的数组,并将老数组的内容复制到新数组中。
!!! question "在构建栈(队列)的时候,未指定它的大小,为什么它们是“静态数据结构”呢?"
在高级编程语言中我们无须人工指定栈队列的初始容量这个工作是由类内部自动完成的。例如Java 的 ArrayList 的初始容量通常为 10 。另外,扩容操作也是自动实现的。详见本书的“列表”章节。