chapter_array_and_linkedlist/list/ #32
Replies: 63 comments 85 replies
-
仿照大佬Java写了个c++本地运行没啥问题,不会上传 |
Beta Was this translation helpful? Give feedback.
-
介绍数组缺点一项,在数组中插入或删除元素效率低下课题下,丢失元素或是否是语病? |
Beta Was this translation helpful? Give feedback.
-
线性表的顺序存储,就是您这章所讲的列表吗? |
Beta Was this translation helpful? Give feedback.
-
在列表末尾添加元素是不是也不严格为O(1),比如某些情况下列表正好需要先扩容再添加,这时候时间复杂度就会是O(N)。请问Python中的list是否也会存在这种问题? |
Beta Was this translation helpful? Give feedback.
-
如果创建多线程,并发的情况下,对同一个List操作,它怎么判断size的执行顺序 |
Beta Was this translation helpful? Give feedback.
-
cpp 中,vector 成员函数 size 的返回值类型为 size_type vector<int> list = { 1, 3, 2, 5, 4 };
...
int count = 0;
- for (int i = 0; i < list.size(); i++) {
+ for (size_t i = 0; i < list.size(); i++)
count++;
} |
Beta Was this translation helpful? Give feedback.
-
在最后的my_list.cpp中的 void extendCapacity() 方法似乎没有考虑整型溢出的风险(int newCapacity = capacity() * extendRatio;),由于extendRatio和numsCapacity都是int型,我认为这个风险还是蛮大的。或者说在这部分针对初学者的内容中暂时不用考虑这么细致? |
Beta Was this translation helpful? Give feedback.
-
大佬,C语言版本的动态数组没有嘛,我记得C primer plus 有讲 |
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.
-
不好意思我想请问一下,在列表类实现中,“# 新建一个长度为 self.__size 的数组,并将原数组拷贝到新数组”是否应该为“新建一个长度为 self.__nums 的数组“? |
Beta Was this translation helpful? Give feedback.
-
could you give me some explanation about the "new" and "delete[]" operator? why we double "new" int[] for nums,why need delete[] tmp? the below is comment by CHATGPT: To fix this, you can simply remove the line delete[] tmp;, as it is unnecessary and could lead to issues if you intend to continue using the nums array. |
Beta Was this translation helpful? Give feedback.
-
里面的注释,索引i应该是j。 |
Beta Was this translation helpful? Give feedback.
-
看评论就学到了很多 |
Beta Was this translation helpful? Give feedback.
-
请问这里是不是有个bug啊?在vscode里显示 |
Beta Was this translation helpful? Give feedback.
-
请问这个 |
Beta Was this translation helpful? Give feedback.
-
这样删不掉最后一个元素吧? |
Beta Was this translation helpful? Give feedback.
-
为什么我在vscode中使用 |
Beta Was this translation helpful? Give feedback.
-
void delMyList(MyList *nums){
free(nums->arr);
free(nums);
} 中free(nums->arr)不是包含在free(nums)中吗?只用后者可以吗? |
Beta Was this translation helpful? Give feedback.
-
// C 未提供内置动态数组 |
Beta Was this translation helpful? Give feedback.
-
你好,这句话: |
Beta Was this translation helpful? Give feedback.
-
Java列表的实现中,是不是没有做缩容的操作(doge |
Beta Was this translation helpful? Give feedback.
-
c++ sort函数的区间是左闭右开的, sort(nums.begin(), nums.end()) , nums.end()指向的最后一个元素外的一个地址,所以是对nums的所有元素排序。 但是 sort(nums.begin(), nums.begin()+8),因为左闭右开,取不到第8个元素,应该只是对前7个元素排序吧,可是运行的结果是对前8个元素排序了。 请问如何理解这个左闭右开 |
Beta Was this translation helpful? Give feedback.
-
十分感谢!我在手动敲打每行代码学习。好像发现一个无关紧要的小问题,my_list.cpp, line159,这个注释里,好像应该是在 i = 4会导致容量超出。 |
Beta Was this translation helpful? Give feedback.
-
大佬好,可否在这里添加 C语言通过malloc 申请分配内存的 方式作为动态数组实现呢 |
Beta Was this translation helpful? Give feedback.
-
这个章节不是list吗?不是标准库中的std::list吗?这个std::vector,这个中文不是应该翻译成向量,或者动态数组可变数组吗?我一开始看到说list可以实现快速访问,中括号都用上了,我还以为我 std::list一直用错了呢 |
Beta Was this translation helpful? Give feedback.
-
List nums = new ArrayList<>(Arrays.asList(numbers)); |
Beta Was this translation helpful? Give feedback.
-
vector nums = { 1, 3, 2, 5, 4 }; |
Beta Was this translation helpful? Give feedback.
-
请问列表实现中的构造函数newMyList里,malloc前面为什么不用强转类型? |
Beta Was this translation helpful? Give feedback.
-
chapter_array_and_linkedlist/list/
Your first book to learn Data Structure And Algorithm.
https://www.hello-algo.com/chapter_array_and_linkedlist/list/
Beta Was this translation helpful? Give feedback.
All reactions