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
The purpose of​ a/an _________ system is to capture best practice solutions and program them into a set of rules in a software p
Dmitriy789 [7]
The purpose of an expert system is to capture best practice solutions and program them into a set of rules in a software program. Expert systems are computers that use artificial intelligence technologies to simulate a behavior of a human or another subject. 
The knowledge about a specific subject is transformed with this system into a software code. 
8 0
3 years ago
Assign listNodes with all elements with a clasa name prog-lang
ra1l [238]

Using the knowledge in computational language in JAVA it is possible to write a code that Assign listNodes with all elements with a clasa name prog-lang

<h3>Writting in JAVA:</h3>

let listNodes;

 //assigning listNodes with all elements with a class name of 'special-language'

  listNodes = document.getElementsByClassName('special-language');

 //for loop to traverse all node in listNodes and print every element in it with class name special-language

 for (let i = 0; i < listNodes.length; i++) {

     console.log(listNodes[i].innerHTML);

 }

See more about JAVA at brainly.com/question/12975450

#SPJ1

8 0
1 year ago
The factors of power of device
LUCKY_DIMON [66]

Answer:

tfopod

Explanation:

5 0
2 years ago
C - Language Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. E
Jobisdone [24]

Answer:

Replace

/* Your solution goes here */

with

printf("%d",runTimes[0]);

printf("%d",runTimes[1]);

printf("%d",runTimes[2]);

Explanation:

The question requires that the first three elements of array runTimes be printed;

The first three elements are the elements at the first, second and third positions.

It should be noted the index of an array starts at 0;

  • So, the first element has 0 as its index
  • The second has 1 as its index
  • The third has 2 as its index

So, to make reference to the first three elements, we make use of

<em>runTimes[0], runTimes[1] and runTimes[2]</em> respectively

Having mention the above;

It should also be noted that array is of type integers;

So, to display integers in C, we make use of "%d";

Hence, the print statement for the first three elements is

printf("%d",runTimes[0]);

printf("%d",runTimes[1]);

printf("%d",runTimes[2]);

8 0
3 years ago
HELP PLSSSSS!!! I WILL MARK BRAINLIEST FOR THE FIRST AND CORRECT ANSWER!!!
dalvyx [7]
The answer you are looking for would be A. Hardware can be an external tool, where as software is an internal tool. Hope this helped!
6 0
3 years ago
Read 2 more answers
Other questions:
  • a supermarket having a sale on canned foods' the sale includes 12 cans of soup for 10.65 what is the unit price per can of soup
    6·2 answers
  • If you're using the paintbrush tool and want to change the color of the paint being used what should you change
    6·1 answer
  • What is Napoleon's friend's full name? From the Napoleon Dynamite movie.
    9·2 answers
  • A technician wants to consolidate and log specific alerts from network devices into a database so maintenance tasks and potentia
    11·1 answer
  • A lookup field allows the user to select from a list of values when updating the contents of a field. true or false.
    11·1 answer
  • A Layer 2 switch configuration places all its physical ports into VLAN 2. The IP addressing plan shows that address 172.16.2.250
    7·1 answer
  • Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (
    12·1 answer
  • What feature sets Macs apart from other operating systems?
    5·1 answer
  • In binary, the second digit from the right is multiplied by the first power of two, and the _____ digit from the right is multip
    10·2 answers
  • Explain how to add cell A1 and cell B3 in excel
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!