[操作疑難] Linked List 問題

如果我有個 Array[1000]
我想抽第 500 個出嚟,
可以好直接咁 x=Array[499]

但如果係 linked list,
我要 next 500 次,
會唔會有好啲嘅方法?

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

唔會
如果你想要direct access, 根本一開始就唔應該用linked list

TOP

The elements of a linked list are only accessible in a sequential manner. Hence to access any element, we have to iterate through each node one by one until we reach the required element.

TOP