Interview Questions

251.Given a text file, implement a solution to find out if a pattern similar ....

Microsoft Interview Questions and Answers


(Continued from previous question...)

251.Given a text file, implement a solution to find out if a pattern similar ....

Question:
Given a text file, implement a solution to find out if a pattern similar to wild cards can be detected. fort example find if a*b*cd*, or *win or *def* exists in the text.


maybe an answer:


match_exp (char *exp, char *text){
if (exp=='\0'){
return true;
} else if (*(exp+1)=='*'){
text = match_star(*exp, text);
exp = exp + 2;
return match_exp(exp, text);
} else if (*exp==*text){
exp++;
text++;
return match_exp(exp, text);
} else {
return false;
}
}

match_star (char c, char *text){
while(c==*text++);
return text;
}

(Continued on next question...)

Other Interview Questions