lab5 - CSS 342: Mathematical Principles of Computing Lab 5:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSS 342: Mathematical Principles of Computing Lab 5: Linked Lists Professor: Munehiro Fukuda Assigned: See Our Syllabus Purpose This laboratory work implements and evaluates the performance of an MTF (move-to-front) list and a transpose list by modifying the find function of a doubly linked list. MTF List The concept of MTF lists places the most recently used item to the top of a list, and thus the least recently used item will eventually move to the trail. Given more "find" operations than "delete" or "insert", MTF alleviates the cost of locating items that need to be frequently accessed. The algorithm is implemented in find( ) as follows: template<class Object> DListNode<Object> *top = DList<Object>::header->next; DListNode<Object> *found = top; for ( ; found != NULL && found->item != obj; found = found->next ) ++DList<Object>::cost; if ( found == NULL ) return -1; // not found if ( found == top ) return 0; // no need to move to front // remove found from the current position // insert found between header and top return 0; } Transpose List The concept of transport lists swaps the most recently used item with its neighbor that is closer to the top. The more frequently access the closer to the top does an item move. Therefore, all list items will be eventually ordered in their frequency of being accessed. The algorithm is implemented in find( ) as follows: template<class Object> DListNode<Object> *found = DList<Object>::header->next;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/20/2009.

Page1 / 4

lab5 - CSS 342: Mathematical Principles of Computing Lab 5:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online