A New Proposed Cost Model for List Accessing Problem using Buffering

There are many existing well known cost models for the list accessing problem. The standard cost model developed by Sleator and Tarjan is most widely used. In this paper, we have made a comprehensive study of the existing cost models and proposed a n…

Authors: Rakesh Mohanty, Seetaya Bhoi, Sasmita Tripathy

International Journal of Computer Applications (0975 – 8887) Volume 22 – No.8, May 2011 19 A New Proposed Cost Model for List A ccessing Problem using Buffering Rak es h M oha nty Dept . of Co mp. Sc . & En gg. In dian In sti tute of Tec hn olog y Mad ras , C henn ai, In dia Seetaya Bhoi Dept . of Co mp. Sc . & Engg Vee r S ure ndra Sa i In sti tut e o f Tech nol ogy Bu rla, Ori ssa , I nd ia Sas mit a Tr ip ath y Dept . of Co mp. Sc . & Engg Vee r S ure ndra Sa i In sti tut e o f Tech nol ogy Bu rla, Ori ssa , I nd ia ABSTRACT There are man y existing well known cost m odels for the list accessing problem. The stand ard cost model d eveloped by Sleator and Tarjan is most widely used. In this p aper, we h av e made a comprehensive study of the existing cost models and proposed a new cost model for the list accessing problem. In our proposed cost m odel, for calculating the p rocessing cost of request sequ ence using a singly linked list, we consid er the access cost, matching cost and replacement cost. T he cost o f processing a request sequence is the su m o f a ccess cost, matching cost and replacement c ost. We have proposed a novel method for pro cessing the request sequen ce which does not consider the rearrangeme nt of the list and uses th e concept of buffering, matching, look ahead and flag bit. General Terms Data Structures, Algorithms, Linked List, Linear L ist, Data Compression. Keywords Data Structure, Linear List, List Access ing, Cost model, buffering, look ahead, matching. 1.INTRODUCTION The list accessing prob lem involves maintaining and organizing a dictionary as a li near list. A dictio nary is an abstract data type that stores and m aintains a set of elements and supports the operations access, insert, and delete. For accessing an element, the list is traversed from the start o f the list until the requested element is found. The insertion operation involves addition of an element at the end of the list. An element is deleted by first searching for the element and then removing it. As insertion and deletion of an element can be co nsidered as a special case of access operation, therefore we can con sider the access operation only for maintaining and organizing the dictionary. 1.1 Problem Statement In list accessing prob lem, an unsorted linear list L of l d istinct elements is given as input along with a finite sequence of requests o f size n such that (n ≥ l). Here each input request is an access operation . The list accessing algorith m takes an unsorted linear list and a request seq uence as input and serv es th e requests in order of their arriva l. A request is said to be served, when an access operation is performed o n the requested element by incurring some access cost. Accessing an element „x‟ at position „i‟ from th e front of the list costS „i‟. Our goal is t o reduce th e total acc ess cost while serving a request sequence on the list. 1.2 Applications The list access ing techn ique is extensively used in storing and maintaining small dictio naries. One important app lication of list accessing technique is data compression. Other applications include computing point maxima and convex hulls in computational geometry, organizing the list o f identifiers maintained by a compiler and resolving collisions in a hash table. The list accessing problem is also of significant in terest in the contest of self organizing data structures . 1.3 Related Work The list accessing techniq ues were initiated by the pioneering work of McCabe in 1965[1]. He investigated th e problem of maintaining a seq uential file and d eveloped two algorithms Move To Fron t and Transpose. Sleator and Tarjan in 1985 proposed a standard full cost m odel for th e list accessing problem[2], which is the m ost widely u sed cost model. It involves f ree e xchanges and pa id ex changes to rearrange the input list. The partial cost model[3 ] assigns the cost by coun ting the number o f co mparisons. A com prehensive su rvey o f List Accessing P roblem a long w ith various cost m odels has been done in [4], [5], [6], [ 7], [8]. 1.4 Our Contribution In this p aper, we have m ade a s tudy o f different existing cost models for list accessin g problem and prop osed a new cost model. The u niqueness of our proposed cost model is that it assigns the cost usin g the concep t of b uffering, the look ahead and matching. We have pro posed an algorithm which involves above concepts and calculate th e cost b y using ou r proposed model. This algorithm does not involve the rearrangeme nt of the inpu t list. We have also analysed the performance of proposed cost model by using the developed algorithm. 1.5 Organization of Paper This paper is organised as fo llows. Section II contains description of well known cost models and some well known list accessing algorithms. Section III presents our new pro posed cost model and evaluation of access c ost using ou r model for the list accessing problem.. S ection IV provides th e concludin g remarks and scope of future research work . 2. PRELIMINARIES 2.1 Cost Models When an ele ment is accessed in th e lin ear list, a cost is assigned to it. This assignment of cost is defined b y different cost models. There are various cost models f or th e list accessing problem using singly linked li st d ata structure such as full cot model, International Journal of Computer Applications (0975 – 8887) Volume 22 – No.8, May 2011 20 partial cost model, paid exchange model etc. A start po inter is pointed to the begin ning of the list and t he list is t o be traversed from the start pointer till the requested element is foun d in the list. The two most widely used cost models for list accessing problem usin g sin gly lin ked list are Full cost Model and Partial cost Model. These models assume that after an item has been requested, it may b e moved free o f charge closer to the front of the list. This is called a free exchange . Any oth er exchange o f two consecutive item s in the list incurs cost one and is called a paid exchange . 2.1.1 Full Cost Model The full cost model developed by Sleator and Tarjan[2] is considered as the standard cost model for list accessing problem. According to this m odel, the cost for accessing a requested element is equal to the position of that element from th e front of the list. F or example, the cost o f accessing an element „x‟ at the i th position in the input list is equal to i. 2.1.2. Partial Cost Model In partial cost model[3], t he cost for acc essing an element is the n umber of comparisons required f or accessing the requested element in th e input list. For exam ple, the cost of accessing an element „x‟ at the i th position in the input list is equal to i- 1. 2.1.3 P d Cost Model Manasse et. al[6] and Reingold et.al[7] introduced the P d cost model. In th is m odel there are no free exchanges and each paid exchange costs d. 2.1.4. Centralized Cost Model A cost model using doubly linked list, known as Centralised cost model, w as developed b y R. Mohanty et.al [ 6]. According to this cost model, access cost for a requ ested element is equ al to its distance from the c entral element o f the list. Free m ovement is moving the cu rrently accessed element to an y p osition forward or backward in the list towa rds the centre of the list with no cost. Paid movement is an y exchanges oth er than the free movement . The co st incurred for paid movement is the d istance between the elements to be exchanged. 2.2 List Accessing Algorithms Many algorithms have been developed for th e list accessing problem . The primitive algorithms are MT F, TRANSPOSE, and FC. MTF: After accessing an element, the eleme nt is moved to th e front of the list with no cost, without changing the relative order of the other elements in the list. TRANSPOSE: After a ccessing an element o f the list, it is exchanged with the immediately preceding element. FREQUENCY COUNT: It maintains a frequency count for each element of the list, the count is i nitialised to zero. Then increase the count of an elem ent b y on e whenever it is accessed and maintains the li st so that the elements are in non -increasing order of their frequency c ount. 3. OUR PROPOSED COST MODEL We have proposed a new cost model using the concept of buffering, look ahead and matching. In our proposed cost model, we h ave defined and u sed the following terminologies. A List is a sequence of unsorted distinct elements. Request sequence is a sequence of elements. Visited list is the p ortion of the List visited while searching for the requ ested element and it is marked by a poin ter. We call this pointer Visitor pointer . Matched elements are th e elements which results from parallel matching of Visited list and the next „i‟ elements of the request sequenc e, where „i‟ is th e position of requested element in th e input List. Buffer is the temporary mem ory which stores the matched ele ments. Flag is an extra bit give n to the matched elements for identification purpose. Flagged elements are the elements, which are ass igned a flag. The access o f f lagged ite m from Bu ffer co sts „i‟ if it is at the i th position in the buffer. T he non flagged elements are accessed from th e list by incurring access cost „i‟ for an element in i th position of the List. 3.1. Assumptions In our proposed cost model, we have assu me d that the list is a singly lin ked list. F or matching operation , we do the parallel matching. The matching cost is assigned as „n‟ w here „n‟ is the number o f matches. Maxi mum allowable Buffer size is given. If nu mbers of matched elements present are m ore than given buffer size, then th e elements having higher ‟i‟ values in the list („i‟ is the position of elem ent in the li st) are placed in buffer. The list siz e is q uite large. The vi sitor po inter always starts fro m starting of the list for each access in the list. In o ur proposed method, we use look a head of „i‟ from accessed element in request sequ ence. Here we know next „i‟ elements from accessed elements in request sequence. 3.2. Proposed Cost Model There are many existing cost models f or list accessing problem. The previously existing cost models assum e that the cost of rearrangement is zero. In o ur cost model, the list is not rearranged and we u se bu ffer to sto re some ele ments for faster accessing. Our cost model assigns the processing cost of the request sequence as follows: 1. Th e cost of accessing an element x at the i th position in the input list and buffer is equal to i. ‟ 2. The matching cost is n, where n is the number of parallel matches . 3. As b uffer space is limited, rep lacement o ccurs. The replacement cost is m where m is the n umber of elements replaced in buffe r. 4. The processing cost of the request sequen ce is the sum of access cost, matching cost and replacem ent cost. International Journal of Computer Applications (0975 – 8887) Volume 22 – No.8, May 2011 21 Input list total cost request sequence Buffer Fig 1: Representatio n of proposed cost m odel 3.3 Pseudo code For Our Proposed Algorithm Illustration Gi ven list L=A B C D E F G H I and Request sequence R= I E G D I E D A B I and given buffer size is 3. We read I fro m L and access it with cost 9 as it i s the ninth element in list. T he visited li st V L is mark ed by th e visitor pointer and will be A B C D E F G H I. The elements of th e look ahead „i‟ are Next 9 elements o f R from I i. e, NR i = E G I E D A B I. They are matched with V L . Match(V L, NR i )= E I . Matching cost is 2 as two matches occur in parallel matching . Then we store E I in Buffer B. Give flag to E I within look ahead „i‟ i.e, within next 9 positions from I in R. Next r equested element is E, which is flagged. So access it from buffer with cost 1 as it is th e first element in buff er. Then req uested eleme nt is G, as it is n on- flagged, it is accessed from L with cost 7. The visitor pointer mark th e visited list V L = A B C D E F G. Here NRi=D I E D A B I Match(V L , NR i ) = D. Matching cost is 1. Already there are two elements in buffer and D is th e third element . As buffer size is 3, no replacement needed. No w b uffer con tains E I D. Next element is D in R, as it is flagged , it is accessed from buffer with cost 3 as it is at th e third p osition in buffer . The n ext request is I, it is flagg ed so it is accessed f rom b uffer with cost 2. Then E is requested. As it is flagged, the item is access ed from buffer with cost 1. Next requ est is for D, it is flagged. So it is accessed from buffer with cost 3 . Next requ est is for A. It is n on flagged, so it is access ed fro m list and V L marked by visitor pointer is V L = A. NR i =B. No matches occur in parallel matching so buffer content remains the same. Next requested element is B. It is non -flagged. So it is access ed from L with cost 2 . The V L pointed by visitor po inter will be A B. NR i = I. No matching occurs so bu ff er content rem ains same. Next request is I, it is flagged so it is accessed fro m buffer with cost 2.. So the to tal cost for th e above request sequence according to propo sed cost model is 34. I/P: List L, Request sequence R, Buffer B.(parameters: List size, R equest sequence size, Buffer size) Read th e requ ested element from the list L and mark the Visited list V L by visitor pointer Match V L with elements of R in lo ok ahead „i‟(where „i‟ is the position of eleme nt in L) fro m accessed element. Match(NR i , V L )=(M 1, M 2,.............. M J ) No Yes Fig. 2 Flow Chart for Our Propo sed Algorithm Access cost + Matching cost + Replacement cost PAlgo(List, Request Sequence, Buffer) 1. Here given list is L= L 1, L 2, ................. ........ .,L n , Request sequence is R= R 1, R 2, ................ .........,R m where m≥ n and Buffer size is b. where b

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment