We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
内存上是否连续,新增删除的效率,查询的效率,底层数据结构的区别
Sorry, something went wrong.
数组静态分配内存,链表动态分配内存;
数组在内存中连续,链表不连续;
数组元素在栈区,链表元素在堆区;
数组利用下标定位,时间复杂度为O(1),链表定位元素时间复杂度O(n);
数组插入或删除元素的时间复杂度O(n),链表的时间复杂度O(1).
数组在内存上市连续且每个内存大小是相同的,如果插入或者删除,为了保证内存的连续,需要移动大量的内存地址,腾出空间。 而链表内存不是连续的,而是通过指针来讲上下两个元素联系起来,因此插入和删除元素都不需要移动内存,只需要改变指针指向。所以数据适合访问,链表适合插入移除。另外数组是在栈中分配内存,而链表是在堆中分配内存。
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: