Wednesday, April 9, 2008

An interesting string pattern analysis problem

Given a binary string S 01...010 with N bits, and a string comparison operator Op(s1, s2) with outputing only 1 bit value. Suppose the binary string S have K "1".

Please give an algorithm to decide the positions of all the bits valued 1 and analyze its time compleixty in terms of operation. Can we even analyze the overall time complexity with the time complexity of operation.

1 comment:

Jingdong Wang (王井东) said...

Considering an extreme case with K = 1, binary-search may find the position with time complexity O(logN)operations.