{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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> int MtfList<Object>::find( const Object &obj ) { 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> int TransposeList<Object>::find( const Object &obj ) { DListNode<Object> *found = DList<Object>::header->next;

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online