promotion image of download ymail app
Promoted
匿名使用者
匿名使用者 發問時間: 電腦與網際網路程式設計 · 5 年前

刪除鏈結串列的問題

Describe the algorithm (use figures if you need) that you can free a linked list in O(1) time.

1 個解答

評分
  • 5 年前
    最佳解答

    1. replace the delete operator of your class by your own operator where the deleted link list is added to the front of your list.

    2. replace the new operator of your class by your own operator where the new instance is to be allocated from your list, until the list becomes empty. Then you use the system heap.

    • Commenter avatar登入以對解答發表意見
還有問題?馬上發問,尋求解答。