fixed out of bound exception in shared_prefix function
optimized shared_prefix
Merge pull request #6 from Incubaid/shared-prefix-bug

fixed out of bound exception in shared_prefix function