Black-White Array: A New Data Structure for Dynamic Data Sets

04/20/2020
by   Z. George Mou, et al.
0

A new array based data structure named black-white array (BWA) is introduced as an effective and efficient alternative to the list or tree based data structures for dynamic data set. It consists of two sub-arrays, one white and one black of half of the size of the white. Both of them are conceptually partitioned into segments of different ranks with the sizes grow in geometric sequence. The layout of BWA allows easy calculation of the meta-data about the segments, which are used extensively in the algorithms for the basic operations of the dynamic sets. The insertion of a sequence of unordered numbers into BWA takes amortized time logarithmic to the length of the sequence. It is also proven that when the searched or deleted value is present in the BWA, the asymptotic amortized cost for the operations is O(log(n)); otherwise, the time will fall somewhere between O(log(n)) and O(log^2(n)). It is shown that the state variable total, which records the number of values in the BWA captures the dynamics of state transition of BWA. This fact is exploited to produce concise, easy- to-understand, and efficient coding for the operations. As it uses arrays as the underlying structure for dynamic set, a BWA need neither the space to store the pointers referencing other data nodes nor the time to chase the pointers as with any linked data structures. A C++ implementation of the BWA is completed. The performance data were gathered and plotted, which confirmed the theoretic analysis. The testing results showed that the amortized time for the insert, search, and delete operations is all just between 105.949 and 5720.49 nanoseconds for BWAs of sizes ranging from 210 to 229 under various conditions.

READ FULL TEXT

Please sign up or login with your details

Forgot password? Click here to reset