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
Subscribe to my you tube channel to get all your questions answered
vredina [299]

kaaaaaaaaaaaaaaaaa

aaa

4 0
3 years ago
Which file system is designed to verify and autocorrect data faults on the volume without having to bring the volume down for ma
Aloiza [94]

Answer: ReFS or Resilient File System.

The ReFS system was actually built from the NTFS (New Technology File System). The ReFS has similar features, but also comes with a built-in scanning system. The ReFS constantly checks your data constantly for corrupted data. The ReFS also supports larger volumes of drives and can support up to 32,768 characters.

6 0
3 years ago
/ List the seven basic internal components found in a computer tower.
JulsSmile [24]
The 7 components found in a computer tower are the following:
Power supply unit
Central processing unit
Hard disk drive
Ram modules
Motherboard
Video card
Sound card
3 0
3 years ago
Read 2 more answers
If your vehicle leaves the pavement for any reason, remember to take your foot off the gas pedal, hold the wheel firmly, and____
aleksandr82 [10.1K]
A- and steer in a straight line 
8 0
3 years ago
Read 2 more answers
Select the correct answer.
Gnesinka [82]

Answer:

D.

Explanation:

I think.

4 0
2 years ago
Other questions:
  • Which of these BEST describes an inference?
    11·2 answers
  • What is meant by polling mode in communication between software andUART and what is its disadvantage as compared to interrupt mo
    14·1 answer
  • 1
    5·2 answers
  • What is the forging of the return address on an email so that the email message appears to come from someone other than the actu
    11·1 answer
  • What is the best platform for a online meeting?
    10·2 answers
  • How should tools be stored <br>​
    13·1 answer
  • Question #5
    15·2 answers
  • Compare and contrast two fundamental security design principles in network security. Analyze how these principles and how they i
    15·1 answer
  • Need help:(!!!! I’ll mark brainliest if correct
    5·1 answer
  • KELLY Connect
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!