Efficient Adaptive Data Compression using Fano Binary Search Trees

Similar documents
A Distribution-Sensitive Dictionary with Low Space Overhead

Experimental Evaluation of List Update Algorithms for Data Compression

arxiv: v2 [cs.it] 15 Jan 2011

ICS 691: Advanced Data Structures Spring Lecture 3

arxiv: v2 [cs.ds] 9 Apr 2009

ADAPTIVE SORTING WITH AVL TREES

Red-Black, Splay and Huffman Trees

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm

Search Trees - 2. Venkatanatha Sarma Y. Lecture delivered by: Assistant Professor MSRSAS-Bangalore. M.S Ramaiah School of Advanced Studies - Bangalore

Range Mode and Range Median Queries on Lists and Trees

Optimization I : Brute force and Greedy strategy

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

A Comparative Study of Entropy Encoding Techniques for Lossless Text Data Compression

Intro. To Multimedia Engineering Lossless Compression

On the other hand, the main disadvantage of the amortized approach is that it cannot be applied in real-time programs, where the worst-case bound on t

3 Competitive Dynamic BSTs (January 31 and February 2)

Lossless Compression Algorithms

ADVANCED LOSSLESS TEXT COMPRESSION ALGORITHM BASED ON SPLAY TREE ADAPTIVE METHODS

Self Adjusting Data Structures

Splay Trees. (Splay Trees) Data Structures and Programming Spring / 27

Verifying a Border Array in Linear Time

Welcome Back to Fundamentals of Multimedia (MR412) Fall, 2012 Lecture 10 (Chapter 7) ZHU Yongxin, Winson

A New Approach to the Dynamic Maintenance of Maximal Points in a Plane*

Lecture 17. Lower bound for variable-length source codes with error. Coding a sequence of symbols: Rates and scheme (Arithmetic code)

The Encoding Complexity of Network Coding

An Efficient Decoding Technique for Huffman Codes Abstract 1. Introduction

Notes on Binary Dumbbell Trees

arxiv: v3 [cs.ds] 18 Apr 2011

Dynamic Access Binary Search Trees

Advanced Algorithms. Class Notes for Thursday, September 18, 2014 Bernard Moret

Dynamic Access Binary Search Trees

Chapter 4: Trees. 4.2 For node B :

ASYMMETRIC COMMUNICATION PROTOCOLS VIA HOTLINK ASSIGNMENTS

Lecture 2 February 4, 2010

Poketree: A Dynamically Competitive Data Structure with Good Worst-Case Performance

Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT

Lecture 15. Error-free variable length schemes: Shannon-Fano code

A Fast Algorithm for Optimal Alignment between Similar Ordered Trees

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

Bichromatic Line Segment Intersection Counting in O(n log n) Time

Lecture 3 February 20, 2007

EE67I Multimedia Communication Systems Lecture 4

Deterministic Jumplists

8.1. Optimal Binary Search Trees:

Spanners of Complete k-partite Geometric Graphs

Greedy Algorithms. Alexandra Stefan

Text Compression through Huffman Coding. Terminology

HEAPS ON HEAPS* Downloaded 02/04/13 to Redistribution subject to SIAM license or copyright; see

A Connection between Network Coding and. Convolutional Codes

Red-Black Trees. Based on materials by Dennis Frey, Yun Peng, Jian Chen, and Daniel Hood

Quake Heaps: A Simple Alternative to Fibonacci Heaps

Characterization of Request Sequences for List Accessing Problem and New Theoretical Results for MTF Algorithm

Huffman Coding. Version of October 13, Version of October 13, 2014 Huffman Coding 1 / 27

An Optimal Algorithm for the Euclidean Bottleneck Full Steiner Tree Problem

PLANAR GRAPH BIPARTIZATION IN LINEAR TIME

ON WEIGHTED RECTANGLE PACKING WITH LARGE RESOURCES*

6. Finding Efficient Compressions; Huffman and Hu-Tucker

February 24, :52 World Scientific Book - 9in x 6in soltys alg. Chapter 3. Greedy Algorithms

Solutions. Suppose we insert all elements of U into the table, and let n(b) be the number of elements of U that hash to bucket b. Then.

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials)

A more efficient algorithm for perfect sorting by reversals

An Asymmetric, Semi-adaptive Text Compression Algorithm

2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006

Upper Bounds for Maximally Greedy Binary Search Trees

Binary Trees. BSTs. For example: Jargon: Data Structures & Algorithms. root node. level: internal node. edge.

Greedy Algorithms CHAPTER 16

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

On k-dimensional Balanced Binary Trees*

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Horn Formulae. CS124 Course Notes 8 Spring 2018

Greedy Algorithms. CLRS Chapters Introduction to greedy algorithms. Design of data-compression (Huffman) codes

Dictionaries. Priority Queues

Red-black trees (19.5), B-trees (19.8), trees

(2,4) Trees. 2/22/2006 (2,4) Trees 1

THE RELATIVE EFFICIENCY OF DATA COMPRESSION BY LZW AND LZSS

CS301 - Data Structures Glossary By

Trees. Reading: Weiss, Chapter 4. Cpt S 223, Fall 2007 Copyright: Washington State University

Randomized Splay Trees Final Project

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min

A note on Baker s algorithm

A Context-Tree Branch-Weighting Algorithm

4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd

Balanced Binary Search Trees. Victor Gao

Augmenting Data Structures

Algorithms Dr. Haim Levkowitz

(2,4) Trees Goodrich, Tamassia. (2,4) Trees 1

TREES. Trees - Introduction

Trees. (Trees) Data Structures and Programming Spring / 28

CS473-Algorithms I. Lecture 11. Greedy Algorithms. Cevdet Aykanat - Bilkent University Computer Engineering Department

Lecture: Analysis of Algorithms (CS )

S 1. Evaluation of Fast-LZ Compressors for Compacting High-Bandwidth but Redundant Streams from FPGA Data Sources

Analysis of Algorithms - Greedy algorithms -

KIST: A new encryption algorithm based on splay

We assume uniform hashing (UH):

On Covering a Graph Optimally with Induced Subgraphs

Approximating Node-Weighted Multicast Trees in Wireless Ad-Hoc Networks

Information Technology Department, PCCOE-Pimpri Chinchwad, College of Engineering, Pune, Maharashtra, India 2

Chapter 7 Lossless Compression Algorithms

Trees 2: Linked Representation, Tree Traversal, and Binary Search Trees

An Algorithm for Enumerating All Spanning Trees of a Directed Graph 1. S. Kapoor 2 and H. Ramesh 3

Transcription:

Efficient Adaptive Data Compression using Fano Binary Search Trees Luis Rueda 1 and B. John Oommen 2 1 School of Computer Science, University of Windsor 401 Sunset Ave., Windsor, ON N9B 3P4, Canada. Phone +1-519-253-3000 Ext. 3780, Fax +1-519-973-7093 E-mail: lrueda@uwindsor.ca 2 School of Computer Science, Carleton University 1125 Colonel By Dr., Ottawa, ON K1S 5B6, Canada. E-mail: oommen@scs.carleton.ca Abstract. In this paper, we show an effective way of using adaptive self-organizing data structures in enhancing compression schemes. We introduce a new data structure, the Partitioning Binary Search Tree (PBST), which is based on the well-known Binary Search Tree (BST), and when used in conjunction with Fano encoding, the PBST leads to the so-called Fano Binary Search Tree (FBST). The PBST and FBST can be maintained adaptively and in a self-organizing manner by using new tree-based operators, namely the Shift-To-Left (STL) and the Shift-To- Right (STR) operators. The encoding and decoding procedures that also update the FBST have been implemented, and show that the adaptive Fano coding using FBSTs, the Huffman, and the greedy adaptive Fano coding achieve similar compression ratios. 1 Introduction Adaptive lists have been investigated for more than three decades, and schemes such as the Move-to-Front (MTF), Transposition, Move-k-Ahead, the Move-to- Rear families [14], and randomized algorithms [3], and their applicability in compression has also been acclaimed, for example, of the MTF in block sorting [9], and by Albers et al. in [2]. As opposed to this, Binary Search Trees (BSTs) have been used in a wide range of applications that include storage, dictionaries, databases, and symbol tables. In our case, we assume that the (adaptive) BST is dynamically changed while the records are searched for. Heuristics to maintain an adaptive BST include move-to-root heuristic [4], the simple exchange rule [4], splaying [18], the monotonic tree [7], biasing [6], dynamic binary search [13], weighted randomization [5], deepsplaying [16], and the technique that uses conditional rotations [8]. Member of the IEEE. Fellow of the IEEE.

On the other hand, adaptive coding is important in many applications that require online data compression and transmission. The most well-known adaptive coding technique is Huffman coding [17], arithmetic coding [10], interval and recency rank encoding [10], and the Elias omega codes [1]. Adaptive methods for Fano coding have been recently introduced (for the binary and multi-symbol code alphabets) [15], which have been shown to work faster than adaptive Huffman coding, and consume one-sixth of the resources required by the latter. Although these methods are efficient, they need to maintain a list of the source symbols and the respective probabilities from which the Fano coding tree can be partially reconstructed at each encoding step. In this paper, we show how we can effectively use results from the field of adaptive self-organizing data structures in enhancing compression schemes. We introduce a new data structure, the Fano BST (FBST), and the corresponding updating operators. Afterwards, we show that by incorporating the FBST into an adaptive encoding algorithm leads to faster compression while achieving comparable compression ratios to its counterpart, the Huffman coding. 2 Fano Binary Search Trees The basis for the particular species of binary search trees introduced in this paper, the FBST, comes from the structure used in the conditional rotation heuristic [8]. Consider a (complete) BST, T = {t 1,..., t 2m 1 }. If t i is any internal node of T, then: P i is the parent of t i, L i is the left child of t i, R i is the right child of t i, B i is the sibling of t i, and P Pi is the parent of P i (or the grandparent of t i ). Using these primitives, B i can also be L Pi if t i is the right child of P i, or R Pi if t i is the left child of P i. Let α i (n) is the total number of accesses to node t i up to time n. τ i (n) is the total number of accesses to T i, the subtree rooted at t i, up to time n, and is calculated as follows: τ i (n) = α j (n). (1) t j T i κ i (n) is the Weighted Path Length (WPL) of T i, the subtree rooted at t i, at time n, and is calculated as follows: κ i (n) = t j T i α j (n)λ j (n), (2) where λ j (n) is the path length from t j up to node t i. By using simple induction, it can be shown that: κ i (n) = t j T i τ j (n). (3) In order to simplify the notation, we let α i, τ i, and κ i be the corresponding values (as defined in the conditional rotation heuristic) contained in node t i at time n, i.e. α i (n), τ i (n), and κ i (n) respectively.

Broadly speaking, an FBST is a BST in which the number of accesses of all the internal nodes are set to zero, and the number of accesses of each leaf represents the number of times that the symbol associated with that leaf has appeared so far in the input sequence. The aim is to maintain the tree balanced in such a way that for every internal node, the weight of the left child is as nearly-equal as possible to that of the right child. Definition 1. Consider the source alphabet S = {s 1,..., s m } whose probabilities of occurrence are P = [p 1,..., p m ], where p 1... p m, and the code alphabet A = {0, 1}. A PBST is a binary tree, T = {t 1,..., t 2m 1 }, whose nodes are identified by their indices (for convenience, also used as the keys {k i }), and whose fields are the corresponding values of τ i. Furthermore, every PBST satisfies: (i) Each node t 2i 1 is a leaf, for i = 1,..., m, where s i is the i th alphabet symbol satisfying p i p j if i < j. (ii) Each node t 2i is an internal node, for i = 1,..., m 1. Remark 1. Given a PBST, T = {t 1,..., t 2m 1 }, the number of accesses to a leaf node, α 2i 1, is a counter, and p i refers to either α 2i 1 (the frequency counter) or the probability of occurrence of the symbol associated with t 2i 1. We shall use both these representation interchangeably. In fact, the probability of occurrence of s i can be estimated (in a maximum likelihood manner) as follows: p i = α 2i 1 m j=1 α. (4) 2j 1 We now introduce a particular case of the PBST, the FBST. This tree has the added property that each partitioning step is performed by following the principles of the Fano coding, i.e. the weights of the two new nodes are as nearly equal as possible. This is formally defined below. Definition 2. Let T = {t 1,..., t 2m 1 } be a PBST. T is an FBST, if for every internal node, t 2i, the following conditions are satisfied: (a) τ Ri τ Li τ 2i+1 if τ Li < τ Ri, (b) τ Li τ Ri τ 2i 1 if τ Li > τ Ri, or (c) τ Li = τ Ri. The algorithm for constructing an FBST from the source alphabet symbols and their probabilities of occurrence can be found in [15]. Each time a partitioning is performed, two sublists are obtained, and two new nodes are created, t n0 and t n1, which are assigned to the left child and the right child of the current node, t n. This partitioning is recursively performed until a sublist with a single symbol is obtained. In order to ensure that T satisfies properties (i) and (ii) of Definition Structure PBST, and also the conditions of Definition Structure FBST, the FBST generated by procedure FanoBST(...) must be rearranged as if each node were

accessed in a traversal order, from left to right. The sorted FBST is generated by invoking procedure FanoBSTSort(...), which produces a list of nodes in the desired order, T = {t 1,..., t 2m 1 }. Remark 2. The structure of the FBST is similar to the structure of the BST used in the conditional rotation heuristic introduced in [8]. The difference, however, is that since every internal node does not represent an alphabet symbol, the values of α 2i are all 0, and the quantities for the leaf nodes, {α 2i 1 }, are set to {p i } or to frequency counters representing them. Clearly, the total number of accesses to the subtree rooted at node t 2i, τ 2i, is obtained as the sum of the number of accesses to all the leaves of T 2i. This is given in the lemma below, whose proof can be found in [15]. Lemma 1. Let T 2i = {t 1,..., t 2s 1 } be a subtree rooted at node t 2i. The total number of accesses to T 2i is given by: τ 2i = s α 2j 1 = τ L2i + τ R2i. (5) j=1 We now present a result that relates the WPL of an FBST and the average code word length of the encoding schemes generated from that tree. For any FBST, T, κ is calculated using (3). By optimizing on the relative properties of κ and τ, we can show that the average code word length of the encoding schemes generated from T, l, can be calculated from the values of κ and τ that are maintained at the root. Note that this is done with a single access without traversing the entire tree. This result is stated in Theorem 1 given below. This is quite an intriguing result. The issue at stake is to compute the expected value of a random variable, in this case, the expected code word length. In general, this can be done if we are given the values that the random variable assumes, and their corresponding probabilities. The actual computation would involve the summation (or an integral in the case of continuous random variables) of the product of the values and their associated probabilities. Theorem 1, whose proof can be found in [15], shows how this expected code word length can be computed quickly without explicitly computing either the product or the summation. However, this is done implicitly, since κ and τ take these factors into consideration. Since the FBST is maintained adaptively, the average code word length is also maintained adaptively. Invoking this result, we can obtain the average code word length by a single access to the root of the FBST. Theorem 1. Let T = {t 1,..., t 2m 1 } be an FBST constructed from the source alphabet S = {s 1,... s m } whose probabilities of occurrence are P = [p 1,..., p m ]. If φ : S {w 1,..., w m } is an encoding scheme generated from T, then l = m i=1 p i l i = κ root τ root 1, (6) where l i is the length of w i, τ root is the total number of accesses to T, and κ root is as defined in (2).

From Theorem 1, we see that the WPL and l are closely related. The smaller the WPL, the smaller the value of l. Consequently, the problem of minimizing the WPL of an FBST is equivalent to minimizing the average code word length of the encoding schemes obtained from that tree. 3 Shift Operators in Partitioning Binary Search Trees The aim of our on-line encoding/decoding is to maintain a structure that maximally contains and utilizes the statistical information about the source. Using this structure, the current symbol is encoded and the structure is updated in such a way that the next symbol is expected to be encoded as optimally as possible. We propose to use our new structure, namely the FBST defined in Section 2, which is adaptively maintained by simultaneously encoding, and learning details about the relevant statistics of the source 3. The learning process requires that two separate phases are sequentially performed. The first consists of updating the frequency counters of the current symbol, and the second involves changing the structure of the PBST so as to maintain an FBST. Other adaptive encoding techniques, such as Huffman coding or arithmetic coding, utilize the same sequence of processes: encoding and then learning. After the encoder updates the frequency counter of the current symbol and the corresponding nodes, the resulting PBST may need to be changed so that the FBST is maintained consistently. To achieve this, we introduce two new shift operators which can be performed on a PBST : the Shift-To-Left (STL) operator and the Shift-To-Right (STR) operator 4. Broadly speaking, these operators consist of removing a node from one of the sublists obtained from the partitioning, and inserting it into the other sublist, in such a way that the new partitioning satisfies the properties of Definition Structure PBST. For the sake of brevity, we exclude the definition of the STR operator, which can be found in [15], and which operates in a similar manner to the STL. The STL operator, performed on an internal node of a PBST, consists of removing the left-most leaf of the subtree rooted at the right child of that node, and inserting it as the right-most leaf in the subtree rooted at the left child of that node. The relation between the STL operator and the Fano code construction procedure is the following. Suppose that a list P = [p 1,..., p m ] has already been partitioned into two new sublists, P 0 = [p 1,..., p k ] and P 1 = [p k+1,..., p m ]. The equivalent to the STL operator for this scenario consists of deleting p k+1 from 3 The structure that we introduce here, namely the FBST, could also be combined with other structure models, such as Markov models, dictionary-based compression, PPM schemes, etc., to achieve much more efficient compression. In this paper, we consider the zeroth-order model. The use of FBSTs with higher-order models is currently being investigated. 4 We have defined these operators in terms of various cases, which is, conceptually, similar to the zig-zig and zig-zag cases of the tree-based operations already introduced in the literature [11, 12, 18].

P 1 and inserting it into the last position of P 0, yielding P 0 = [p 0,..., p k, p k+1 ] and P 1 = [p k+2,..., p m ]. Notation STL: Consider a PBST, T = {t 1,..., t 2m 1 }, in which the weight of each node, t l, is τ l, and the key for each internal node is k l, for l = 1,..., m. Let t i be an internal node of T, R i be also an internal node of T, t j be the left-most leaf of the subtree rooted at R i, B j be the sibling of t j, and t k be the right-most leaf of the subtree rooted at L i. Using this notation, we can identify three mutually exclusive cases in which the STL operator can be applied. These cases are listed below, and the rules for performing the STL operation and the corresponding examples are discussed thereafter. STL-1 : P Pj = t i and L i is a leaf. STL-2 : P Pj t i and L i is a leaf. STL-3 : L i is not a leaf. The STL operator performed in the scenario of Case STL-1 is discussed below. Rule 1 (STL-1) Consider a PBST, T, described using Notation STL. Suppose that the scenario is that of Case STL-1. The STL operator applied to the subtree rooted at node t i consists of the following operations: (a) the value τ k τ Bj is added to τ Pj, (b) k i and k Pj are swapped 5, (c) B j becomes the right child of t i, (d) P j becomes the left child of t i, (e) t k becomes the left child of P j, and (f) t j becomes the right child of P j. Remark 3. The node on which the STL operator is applied, t i, can be any internal node or the root satisfying the Notation STL. The tree resulting from the STL-1 operator is a PBST. This is stated for the operator, in general, in Lemma 2 given below. The complete proof of the lemma can be found in [15]. Lemma 2 (STL-1 validity). Consider a PBST, T = {t 1,..., t 2m 1 }, specified as per Notation STL. If an STL operation is performed on the subtree rooted at node t i as per Rule 1, then the resulting tree, T = {t 1,..., t 2m 1}, is a PBST. 5 In the actual implementation, the FBST can be maintained in an array, in which the node t l, 1 l 2m 1, can be stored at position l. In this case, and in all the other cases of STL and STR, swapping these two keys could be avoided, and searching the node t l could be done in a single access to position l in the array.

The weights of the internal nodes in the new tree, T, are consistently obtained as the sum of the weights of their two children. This is achieved in only two local operations, as opposed to re-calculating all the weights of the tree in a bottom-up fashion. We now provide the mechanisms required to perform an STL operation when we are in the scenario of Case STL-2. Rule 2 (STL-2) Consider a PBST, T = {t 1,..., t 2m 1 }, described using Notation STL. Suppose that we are in the scenario of Case STL-2. The STL operator performed on node t i involves the following operations: (a) τ k τ Bj is added to τ Pj, (b) τ j is subtracted from all the τ s in the path from P Pj to R i, (c) k i and k Pj are swapped, (d) B j becomes the left child of P Pj, (e) t j becomes the right child of P j, (f) t k becomes the left child of P j, and (g) P j becomes the left child of t i. Note that the resulting tree is a PBST. The general case is stated in Lemma 3, whose proof can be found in [15]. Lemma 3 (STL-2 validity). Consider a PBST, T = {t 1,..., t 2m 1 }, as per Notation STL. The resulting tree, T = {t 1,..., t 2m 1}, obtained after performing an STL-2 operation as per Rule 2 is a PBST. The corresponding rule for the scenario of Case STL-3 satisfying Notation STL is given below in Rule 3. Rule 3 (STL-3) Consider a PBST, T = {t 1,..., t 2m 1 }, specified using the notation of Notation STL, and the scenario of Case STL-3. The STL operator performed on the subtree rooted at t i consists of shifting t j to the subtree rooted at L i in such a way that: (a) τ k τ Bj is added to τ Pj, (b) τ j is subtracted from all the τ s in the path from P Pj to R i, (c) τ j is added to all the τ s in the path from P k to L i, (d) k i and k Pj are swapped, (e) B j becomes the left child of P Pj, (f) t j becomes the right child of P j, (g) t k becomes the left child of P j, and (h) P j becomes the right child of P k. Observe that in the STL-3 operation, all the nodes in the entire path from P k to the left child of t i have to be updated by adding τ j to the weight of those nodes. As in the other two cases, the weight of t i is not changed. We show below an example that helps to understand how the STL-3 operator works.

Example 1. Let S = {a, b, c, d, e, f, g} be the source alphabet whose frequency counters are P = [8, 3, 3, 3, 3, 3, 3]. A PBST, T, constructed from S and P is the one depicted on the left of Figure 1. After applying the STL operator to the subtree rooted at node t i (in this case, the root node of T ), we obtain T, the tree depicted on the right. Observe that T is a PBST. The general result is stated in Lemma 4 given below, and proved in [15]. 6 26 4 26 t i 2 11 P k +3-3 8 15 P j 2 14 8 12 1 8 t k 3 3 a b t j -3+3 6 6 P j 10 9 5 3 B j 7 3 9 3 12 6 c d e 11 3 13 3 f g 1 8 4 6 7 3 10 9 a e 3 3 5 3 9 3 12 6 b c e 11 3 13 3 f g Fig. 1. A PBST, T, constructed from S = {a, b, c, d, e, f, g} and P = [8, 3, 3, 3, 3, 3, 3], and the corresponding PBST, T, after performing an STL-3 operation. The top-most node can be a left child, a right child, or the root. Lemma 4 (STL-3 validity). Let T = {t 1,..., t 2m 1 } be a PBST in which an STL-3 operation is performed as per Rule 3, resulting in a new tree, T = {t 1,..., t 2m 1}. Then, T is a PBST. In order to facilitate the implementation of the STL operator, we present the corresponding algorithm that considers the three mutually exclusive cases discussed above. This procedure is depicted in Algorithm STL Operation. When performing an assignment operation by means of the left arrow,, the operand on the left is the new value of the pointer or weight, and the operand on the right is either the value of the weight, or the value of the actual pointer to a node. For example, L PPj B j implies that the value of the pointer to the left child of P Pj acquires the value B j 6. 4 Fano Binary Search Tree Coding Using the PBST and the underlying tree operations (discussed in Section 3), we now apply them to the adaptive data encoding problem. Given an input sequence, X = x[1]... x[m], which has to be encoded, the idea is to maintain 6 In the actual implementation, B j contains the memory address of the node B j, or the position of B j in a list if the tree is stored in an array.

an FBST at all times - at the encoding and decoding stages. In the encoding algorithm, at time k, the symbol x[k] is encoded using an FBST, T (k), which is identical to the one used by the decoding algorithm to retrieve x[k]. T (k) must be updated in such a way that at time k + 1, both algorithms maintain the same tree T (k + 1). Algorithm 1 STL Operation Input: A PBST, T = {t 1,..., t 2m 1}. The node on which the STL is performed, t i. The left-most leaf of the subtree rooted at R i, t j. The right-most leaf of the subtree rooted at L i, t k. Output: The modified PBST, T. Assumptions: Those found in Notation STL. Method: procedure STL(var T : partitioningbst; t i, t j, t k : node); k i k Pj // swap keys τ Pj τ Pj + τ k τ Bj for l P Pj to R i step l P l do τ l τ l τ j endfor for l P k to L i step l P l do τ l τ l + τ j endfor if t i = P k then // Move P j to the subtree on the left L i P j // STL-1 and STL-2 else R Pk P j // STL-3 endif if t i = P Pj then // B j remains in the right subtree R i B j // STL-1 else L PPj B j // STL-2 and STL-3 endif R Pj t j // t j becomes the right child of its parent L Pj t k ; P k P j // P j becomes the parent of t k P Bj P Pj // Update the parent of B j P Pj P k // New parent of P j is now old parent of t k endprocedure end Algorithm STL Operation To maintain, at each time instant, an FBST, i.e. the tree obtained after the updating procedure, T (k + 1), must satisfy the conditions stated in Definition Structure FBST. Since the PBST structures are maintained at both the encoder and decoder sides, it is up to the updating procedure to ensure that the resulting tree satisfies the conditions stated in Definition Structure FBST.

The updating procedure is based on a conditional shifting heuristic, and used to transform a PBST into an FBST. The conditional shifting heuristic is based on the principles of the Fano coding the nearly-equal-probability property [15]. This heuristic, used in conjunction with the STL and the STR operators defined in this paper, are used to transform a PBST into an FBST. Details of the heuristic, as well as the encoding and decoding algorithms are provided in [15]. 5 Empirical Results To analyze the speed and compression efficiency of our newly introduced adaptive coding schemes, we report the results obtained after running the scheme on files of the Canterbury corpus. Similar results are also available for the Calgary corpus, which can be found in [15]. We also run the greedy adaptive Fano coding presented in [15], and the adaptive Huffman coding algorithm introduced in [17] on the same benchmarks. The results obtained from the tests are shown in Table 1. The first column contains the name of the file. The second column, labeled l X, represents the size (in bytes) of the original file. The next columns correspond to the speed and compression ratio for the Adaptive Huffman Coding (AFC), the adaptive Greedy Fano Coding (GFC), and the adaptive Fano coding that uses FBSTs (FBSTC). Each of the two groups of three columns contains the compression ratio, ρ, calculated as ρ = ( 1 l Y l X ) 100, the time (in seconds) required to compress the file, and the time (in seconds) needed to recover the original file. The compression ratio obtained after running GFC and FBSTC are, as expected, similar. We observe that the FBSTC obtains compression ratios slightly higher (only 0.15%) than the AHC. In terms of compression speed, on small files, GFC is faster than FBSTC, and the latter is significantly faster than AHC. On large files (e.g. kennedy.xls), however, FBSTC is faster than GFC. In fact, the reason why GFC is faster on ptt5 is due to the fact that a high compression ratio is achieved, and the input file contains only a few different symbols, which makes the FBST look like a list. Consequently, its behavior is similar to that of the GFC, with the additional burden of maintaining a complex structure, the FBST. Observe that to compress the file kennedy.xls, GFC takes more than 2.5 times as much time as that of FBSTC. In terms of decompression speed, FBSTC is slower than AHC. However, the former achieves similar speed values for both compression and decompression, which implies an advantage when the entire process has to be synchronized. 6 Conclusions We have shown that we can effectively use results from the field of adaptive selforganizing data structures in enhancing compression schemes. Unlike adaptive lists, which have already been used in compression, to the best of our knowledge,

Table 1. Speed and compression ratio obtained after running the adaptive Huffman coding, the greedy adaptive Fano coding, and the adaptive coding that uses FBST on files of the Canterbury corpus. Similar results are available for the Calgary corpus. File l X AHC GFC FBSTC Name ρ T.Enc. T.Dec. ρ T.Enc. T.Dec. ρ T.Enc. T.Dec. (bytes) (%) (sec.) (sec.) (%) (sec.) (sec.) (%) (sec.) (sec.) alice29.txt 148,481 42.84 2.49 0.48 42.59 1.20 0.99 42.59 1.44 1.33 asyoulik.txt 125,179 39.21 2.37 0.42 39.05 1.25 0.89 39.06 1.31 1.23 cp.html 24,603 33.27 1.87 0.10 33.19 0.30 0.19 33.19 0.88 0.82 fields.c 11,150 35.31 1.77 0.05 34.92 0.14 0.08 34.89 0.52 0.49 grammar.lsp 3,721 37.70 1.70 0.02 37.29 0.05 0.02 37.24 0.32 0.29 kennedy.xls 1,029,744 55.04 6.71 2.90 54.66 11.72 5.76 54.81 4.50 3.86 lcet10.txt 419,235 41.74 4.18 1.41 41.72 3.83 2.84 41.72 2.41 2.19 plrabn12.txt 471,162 43.43 4.40 1.52 43.32 4.20 3.08 43.32 2.33 2.16 ptt5 513,216 79.18 2.57 0.67 79.16 1.68 1.29 79.16 1.86 1.60 sum 38,240 32.48 1.93 0.18 31.50 0.66 0.30 31.42 0.92 0.88 xargs.1 4,227 34.77 1.74 0.02 34.81 0.06 0.03 34.79 0.42 0.38 Total 2,788,958 53.53 31.73 7.77 53.33 25.09 15.47 53.38 16.91 15.23 adaptive self-organizing trees have not been used in this regard. To achieve this, we have introduced a new data structure, the Partitioning Binary Search Tree (PBST), which leads to the so-called Fano Binary Search Tree (FBST) by incorporating the required Fano coding (nearly-equal-probability) property. We have introduced the updating procedure that performs the two new treebased operators, namely the Shift-To-Left (STL) operator and the Shift-To-Right (STR) operator. The encoding and decoding procedures that also update the FBST have been implemented and rigorously tested. Our empirical results on files of the Canterbury Corpus show the salient advantages of our strategy. An open problem that deserves investigation is that of combining the adaptive self-organizing BST methods and other statistical and/or dictionary-based methods, which, undoubtedly would lead to more efficient compression schemes implied by the higher-order models. The resulting advantage can be obtained as a consequence of the additional speed-enhanced updating procedure provided by the adaptive self-organizing tree-based principles. Acknowledgements: This research work has been partially supported by NSERC, the Natural Sciences and Engineering Research Council of Canada, CFI, the Canadian Foundation for Innovation, and OIT, the Ontario Innovation Trust. References 1. R. Ahlswede, T. S. Han, and K. Kobayashi. Universal Coding of Integers and Unbounded Search Trees. IEEE Trans. on Information Theory, 43(2):669 682,

1997. 2. S. Albers and M. Mitzenmacher. Average case analyses of list update algorithms, with applications to data compression. Algorithmica, 21:312 329, 1998. 3. S. Albers and J. Westbrook. Self-organizing data structures. In Amos Fiat and Gerhard Woeginger, editors, Online Algorithms: The State of the Art, pages 13 51. Springer LNCS 1442, 1998. 4. B. Allen and I. Munro. Self-organizining Binary Search Trees. J. Assoc. Comput. Mach., 25:526 535, 1978. 5. C. Aragon and R. Seidel. Randomized Search Trees. Proceedings 30th Annual IEEE Symposium on Foundations of Computer Science, pages 540 545, 1989. 6. S. Bent, D. Sleator, and R. Tarjan. Biased Search Trees. SIAM Journal of Computing, 14:545 568, 1985. 7. J. Bitner. Heuristics that Dynamically Organize Data Structures. SIAM Journal of Computing, 8:82 110, 1979. 8. R. Cheetham, B.J. Oommen, and D. Ng. Adaptive Structuring of Binary Search Trees Using Conditional Rotations. IEEE Transactions on Knowledge and Data Engineering, 5(4):695 704, 1993. 9. S. Deorowicz. Second step algorithms in the burrows-wheeler compression algorithm. Software - Practice and Experience, 32(2):99 111, 2002. 10. D. Hankerson, G. Harris, and P. Johnson Jr. Introduction to Information Theory and Data Compression. CRC Press, 1998. 11. J. Iacono. Alternatives to splay trees with o(log n) worst-case access times. In Proceedings of the 12th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA-01), pages 516 522, 2001. 12. T. Lai and D. Wood. Adaptive Heuristics for Binary Search Trees and Constant Linkage Cost. SIAM Journal of Computing, 27(6):1564 1591, December 1998. 13. K. Mehlhorn. Dynamic Binary Search. SIAM Journal of Computing, 8:175 198, 1979. 14. B.J. Oommen and J. Zgierski. A Learning Automaton Solution to Breaking Substitution Ciphers. IEEE Transactions on Pattern Analysis and Machine Intelligence, PAMI-15:185 192, 1993. 15. L. Rueda. Advances in Data Compression and Pattern Recognition. PhD thesis, School of Computer Science, Carleton University, Ottawa, Canada, April 2002. Electronically available at http://www.cs.uwindsor.ca/ lrueda/papers/phdthesis.pdf. 16. M. Sherk. Self-adjusting k-ary Search Trees and Self-adjusting Balanced Search Trees. Technical Report 234/90, University of Toronto, Toronto, Canada, February 1990. 17. J. Vitter. Design and Analysis of Dynamic Huffman Codes. Journal of the ACM, 34(4):825 845, 1987. 18. H. Williams, J. Zobel, and S. Heinz. Self-adjusting trees in practice for large text collections. Software - Practice and Experience, 31(10):925 939, 2001.