Computer Science, asked by bhanuprakash306050, 27 days ago

Determine the number of character comparisons that will be made by the
brute-force algorithm in searching for the pattern GANDHI in the text
TH ERE.I S_MORE_ TO_LI FE_ THAN .INCREAS ING.ITS _SPEED
(Assume that the length of the text-it is 47 characters long-is known before
the search starts.)​

Answers

Answered by gentryamansharma51
3

Explanation:

The string of “n” characters is referred as text and a string of “m” characters is referred as pattern The pattern “m must be less than or equal to text “n”. That is, m<>

The given text “n” is.

THERE IS_MORE_LIFE_THAN_INCREASING_ITS_SPEED

The given pattern “m” is,

GANDHI

The total number of characters in the text “n” is 47

The total number of characters in the pattern “m” is 6.

In worst case analysis. the brute4orce

Hope it helps uhh bro/ sis have a nice day Dear ☺❤

Answered by dayanandsds15
0

Answer:

43 comparisons.

Explanation:

The algorithm will make 47 − 6 + 1 = 42 trials: In the first one, the G

of the pattern will be aligned against the first T of the text; in the last

one, it will be aligned against the last space. On each but one trial, the

algorithm will make one unsuccessful comparison; on one trial–when the

G of the pattern is aligned against the G of the text –it will make two

comparisons. Thus, the total number of character comparisons will be

41 · 1+1 · 2 = 43..

Similar questions