Begin DoSearch(Context c, CurrInputNode n) MBest = EmptySet PBest = 0.0 If (c, n) is in MemoTable, return best set of mappings Else For each compatible mapping set Mi covering n P1 = P(Mi | C) For each input node Ii that is a child of an input node covered by Mi P2, MCurr = DoSearch(NewContext for Ii, Ii) P1 += P2 Next input node Ii If (P1 > PBest) PBest = P1 MBest = Mcurr End if Next Mi End if Add (PBest, MBest) to MemoTable Return (PBest, MBest) End DoSearch