如題,既然VB有ReDim Preserve作為對動態Array的修改,咁Linked List是否無用?
以往學C / Java時,就有教Data Structure and Algorithm,但係用VB時,是否可以用dynamic array 代取 Linked List 的寫法?
2007-03-09 07:02:32 · 1 個解答 · 發問者 ? 2 in 電腦與網際網路 ➔ 程式設計
用Linked List 做 insertion 效率高一些,還是用dynamic array 做insertion 效率好一些?
2007-03-09 08:07:42 · update #1
A dynamic array allows you to size up or down an array, but does not allow an element to be inserted or deleted as linked lists can do.
To insert an element and keep an array sorted, you would need to move the rest of the elements before insertion.
On the other hand, it is not easy to do a binary search on a linked list.
Also, if the elements are static, i.e. no interactive additions or deletions, an array may do a good job.
So, which choice is better is really up to you, which in turn depends on your application.
2007-03-09 07:11:20 · answer #1 · answered by p 6 · 0⤊ 0⤋