▁the ▁exact ▁form ▁the ▁table ▁for ▁the ▁bad ▁character ▁rule ▁should ▁take , ▁but ▁a ▁simple ▁constant - time ▁lookup ▁solution ▁is ▁as ▁follows : ▁create ▁a ▁ 2 D ▁table ▁which ▁is ▁indexed ▁first ▁by ▁the ▁index ▁of ▁the ▁character ▁ ▁in ▁the ▁alphabet ▁and ▁second ▁by ▁the ▁index ▁ ▁in ▁the ▁pattern . ▁This ▁lookup ▁will ▁return ▁the ▁occurrence ▁of ▁ ▁in ▁ ▁with ▁the ▁next - high est ▁index ▁ ▁or ▁- 1 ▁if ▁there ▁is ▁no ▁such ▁occurrence . ▁The ▁proposed ▁shift ▁will ▁then ▁be ▁, ▁with ▁ ▁lookup ▁time ▁and ▁ ▁space , ▁assuming ▁a ▁finite ▁alphabet ▁of ▁length ▁. ▁ ▁The ▁C ▁and ▁Java ▁implementations ▁below ▁have ▁a ▁ ▁space ▁complexity ▁( make _ delta 1 , ▁make Char Table ). ▁This ▁is ▁the ▁same ▁as ▁the ▁original ▁delta 1 ▁and ▁the ▁B M H ▁bad ▁character ▁table . ▁This ▁table ▁maps ▁a ▁character ▁at ▁position ▁ ▁to ▁shift ▁by ▁, ▁with ▁the ▁last ▁instance ▁-- ▁the ▁least ▁shift ▁amount ▁-- ▁taking ▁preced ence . ▁All ▁un used ▁characters ▁are ▁set ▁as ▁ ▁as ▁a ▁sent in el ▁value . ▁ ▁The ▁good ▁suffix ▁rule ▁ ▁Description ▁Dem on str ation ▁of ▁good ▁suffix ▁rule ▁with ▁pattern ▁A NA MP NA M . ▁The ▁good ▁suffix ▁rule ▁is ▁marked ly ▁more ▁complex ▁in ▁both ▁concept ▁and ▁implementation ▁than ▁the ▁bad ▁character ▁rule . ▁It ▁is ▁the ▁reason ▁compar isons ▁begin ▁at ▁the ▁end ▁of ▁the ▁pattern ▁rather ▁than ▁the ▁start , ▁and ▁is ▁formally ▁stated ▁thus :