1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SVEN [57.7K]
3 years ago
7

Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text

Computers and Technology
1 answer:
leonid [27]3 years ago
3 0

Answer:

Total number of character comparison = 43

Explanation:

Using the Brute force algorithm

The string of n characters is known as text, and the string of m characters is known as the pattern.

From the given information:

The text (n)=THERE_IS_MORE_TO_LIFE_THAN_INCREASING_ITS_SPEED

The pattern (m) = GANDHI

The total no of characters that we have in the text = 47

The total number of characters in pattern = 6

For a brute force algorithm;

Since; the first character of the pattern does not exist in the text, then the number of trials made can be attempted can be expressed as = n – m + 1

= 47 – 6 + 1

= 47 – 5

= 42

Thus; the algorithm will attempt the trial 42 times.

Now, for loop in the algorithm to run 42 times, the G in the pattern will have to align against the for T in the text, and in the last case, it will be aligned against the last space.

On each attempted trial, the algorithm will make one unsuccessful comparison.

However, at the trial at which the G in the pattern Is aligned with the G in the text, there will be two successful comparisons.

Hence, we can calculate the total number of character comparison as follows:

Total number of character comparison = \mathbf{\bigg ( ( 42 -  (no. \ of \  failed \ comparison) ) \times 1 + (1 \times ( Two \ successful \  comparisons) ) \bigg ) }

Total number of character comparison = ( (( 42 – 1) × 1 ) + ( 1 × 2) )

Total number of character comparison = 41 + 2

Total number of character comparison = 43

You might be interested in
Match the item to the type.
I am Lyosha [343]

Answer:

a. hardware - 3. motherboard

b. software - 2. Microsoft Word

c. input device - 4. mouse

d. operating system - 1. windows

7 0
3 years ago
Read 2 more answers
Can someone help me pz?
Katarina [22]
Yes definitely. now what do you need help with?
8 0
3 years ago
Assume that the "read/write file to hard disk" library is part of the kernel. Assume that this library uses 1MB of RAM. Assume t
scZoUnD [109]

Answer:

The Answer is 1 MB.

Explanation:

In order to replace the library it must write 0 MB to hard drive then only it can be replaced. Therefore 1 MB is the correct answer.

5 0
4 years ago
A _____ network is one in which all network devices are connected to one another through a single central device called the hub
Lana71 [14]
I think it’s mesh because
5 0
3 years ago
a sports car is advertised to be able to reach 60 mph in 5 seconds flat, corner at 0.85 g , and stop from 70 mph in only 168 fee
Hitman42 [59]
T, 0-60 in 5 is slow, 0.85 g is not a lot, and 168 feet is a lot of space to stop a car from 70 MPH, also it depends on what car it is. if its a lotus, they lied, if it is a civic si, possible, if its a corvette, no problem, if its a mustang, possible, if its a camaro, possible, also depends on the year, if its a 1908 ford model t, hold on to a clock with out second hand to get to 60
5 0
3 years ago
Other questions:
  • What helps in determining the reliability of a person to repay debt?
    12·2 answers
  • consider a group of 30 people who wish to establish pair-wise secure communications using symmetric-key cryptography. How many K
    15·1 answer
  • Micheal has increased the contrast of the given picture. Which feature or menu option of a word processing program did he use? A
    15·1 answer
  • select all examples of proper keyboarding technique. rest your fingers gently on the home row or home keys. slouch in your chair
    9·2 answers
  • Create a subclass of Person called Lecturer that has 2 variables of its own: employeeNumber and salary. As in the above scenario
    12·1 answer
  • Express 0.0005 x 10-4 farads as picofarads
    5·2 answers
  • Question 14. 14. PowerPoint assumes every new slide, except for a blank slide, has _____.
    13·1 answer
  • Ann, a customer, purchased a pedometer and created an account or the manufacturer's website to keep track of her progress. Which
    14·1 answer
  • Why vechiles Tyres are black in colour?​
    14·1 answer
  • Question 2:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!