troubleshooting Question

Sequential Search

Avatar of cancer_66
cancer_66Flag for United Arab Emirates asked on
Java
49 Comments1 Solution584 ViewsLast Modified:
Guys a new some help in my Sequential Search.

ill explain with an example. since i feel it is easier for me to explain

let assume ive got

user input: Graphics
Pattern: is defined as
Sentence in file: Graphics is purely defined as a field in Computer Science

1)u.input = Graphics = first token of the sentence (Sentence_token)

2)pattern_token = "is" = Sentence_token

3)pattern_token = "defined" NOTEQUALTO "purely"= Sentence_token  
therefore,Pattern_token (remains same we dont get the next token) = "defined" BUT Sentence_token = "defined"

4)pattern_token = "as" = Sentence_token

5) print Sentence.

take the input from the user and compare it with SENTENCE
     if found than we take the secound token from the SENTENCE and compare it with the first token in the PATTERN
          if equal than get the next token of the PAttern and next token of the SENTENCE and compare again. continue                till we reach have no more tokens.

     else if the token from the PATTERN does not match the token from the SENTENCE than only get the next token for the SENTENCE while keeping the old token of the PATTERN and compare again.

note this is not a Strict sequential search in other words its not nesscary that all the Patterns such as (is defined as) have to come after one another with no words in between.

Hope i made things clear..i written a code but it doesnt work properly..

can anyone help me ..


ASKER CERTIFIED SOLUTION
ozymandias

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 49 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 49 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros