Describe the algorithm (use figures if you need) that you can free a linked list in O(1) time.
- prisoner26535Lv 75 年前最佳解答
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.