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
A _______ area network is a type of wireless network that works within your immediate surroundings to connect cell phones to hea
MakcuM [25]

Answer:

Home

Explanation:

5 0
3 years ago
Read 2 more answers
The Universal Containers research lab is publishing its latest research into knowledge articles assigned to the data category "C
Olenka [21]

Answer:

Option C is correct.

Explanation:

The following research laboratory publishes their new work concerning articles of information allocated to the better standards container classification of information. The community manager needs to ensure all of those posts appear across the Tips and Methods subject field for Community users.

Thus, set up an automatic subject assignment and map the list of Tips and Techniques to the Container good practices group.

8 0
3 years ago
Lan is working on a project report that will go through multiple rounds of
Levart [38]
Its either D or A but im pretty sure its D??
8 0
3 years ago
Computer works on the basis of?​
ASHA 777 [7]
Computer works on the Basis of multitasking.
6 0
2 years ago
Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
Vlad1618 [11]

Answer:

Both careers speak to an audience; however, people involved in the performing arts speak only to a live audience.

Explanation:

sorry im late but im not sure

3 0
3 years ago
Read 2 more answers
Other questions:
  • Why is it more important now than ever before to know how to evaluate websites and other online sources of information?
    7·1 answer
  • Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in
    6·1 answer
  • A virtual private network (VPN) is used to securely connect to another network over a insecure network.
    9·2 answers
  • Company policies require that all network infrastructure devices send system level information to a centralized server. Which of
    6·1 answer
  • Which of the following is an object-oriented prototype-based language? Java Pike REBOL MATLAB
    9·1 answer
  • The primary benefit of a VPN that uses _________ is that an intercepted packet reveals nothing about the true destination system
    6·1 answer
  • Think about some of the most memorable and forgettable games ever created. They can be games that were discussed in this unit or
    10·1 answer
  • Convert the following denary numbers into binary using 8-bit register:
    6·1 answer
  • There are some games that cannot be described by a single--or even two-- genres. Can you think of any that should be invented?​
    6·1 answer
  • Profitability, consumer relations, and competition are involved in what kinds of concerns in the design process?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!