13.10.2014 Views

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

207<br />

Algorithm NonOverlappingScore(node n)<br />

ChildPositions: an array of pointers to arrays<br />

Retval: a pointer to a list of values to return to the calling function<br />

If n.NumChildren == 0 // it’s a leaf node<br />

Allocate Retval with size 1<br />

Retval[0] = n.StringDepth<br />

Return Retval<br />

End If<br />

For i = 0 to n.NumChildren - 1<br />

ChildPositions[i] = NonOverlappingScore(n.Child[i])<br />

End For<br />

Retval = MultiWayMerge(ChildPositions,n.NumChildren)<br />

For i = 0 to n.NumChildren - 1<br />

Deallocate ChildPositions[i]<br />

End For<br />

n.Score = CountUniqueOccurrences(Retval,n.StringDepth) * n.StringDepth;<br />

Return Retval<br />

Figure 9.5: Algorithm NonOverlappingScore<br />

this shortcoming because the algorithm presented to this point will over estimate<br />

the value of some strings. An extension to the algorithm is presented that shows<br />

how overlapping occurrences of candidate strings can be detected and removed from<br />

consideration.<br />

Two occurrences of a substring of s, denoted by w, are known to overlap if the<br />

absolute value of the difference in their starting positions within s is less than |w|.<br />

It is possible to annotate each interior node in the tree with the score based on the<br />

number of non-overlapping occurrences of the substring represented by the node. This<br />

is accomplished using a depth first traversal of the tree using the algorithm shown in<br />

Figure 9.5.<br />

The algorithm presented in Figure 9.5 makes use of a MultiWayMerge operation.<br />

Greene presents an algorithm that is capable of merging y sorted sequences of total<br />

length x in O(x log y) time [52]. In this algorithm, the total length of all of the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!