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
How many bits can a memory chip with the below configuration support? For full credit, show how you got the answer.
tatiyna

Answer:

Total Memory= 4 KB = 4096 bytes = 32768 bits

Explanation:

<em><u>1. Data lines are 8 From D0 to D7</u></em>

so

Total memory at single address locations is 8 bits.

<em><u>2. Address lines are 12 (A0 to A11)</u></em>

There are 12 address lines but 3 out 12 are for selction of chip or memory bank.

so only 9 pins are there to address the locations on one chip.

Total No. of address locations on single chip = 2^9 = 512 locations

as 1 location is 1 byte so total memory of single chip is 512 bytes.

<u><em>3. Total Memory Bank </em></u>

There are total 3 selection pins for memory bank.

so

Total chips = 2^3 = 8.

<em><u>4. Total Memory </u></em>

Total size of 1 chip = 512 bytes

Total size of 8 chip = 8x512 bytes = 4096 bytes = 4096/1024 kb = 4 kb

<em>So total memory of system is 4 Kb = 4096 bytes = 32768 bits</em>

5 0
3 years ago
2
Elza [17]

A is the correct answer.

Hope this helps you!

3 0
3 years ago
Read 2 more answers
HELP ME ASAP
ruslelena [56]

it is title page and give me a ❤

3 0
3 years ago
All of the following are methods to improve the communication of your key messages EXCEPT:
uysha [10]

Answer:

Fill the slides with images and animations

Explanation:

these will most likely distract the audience

6 0
2 years ago
Read 2 more answers
Type the correct answer in the box. Spell all words correctly. How is it possible to access data from any location? Storing data
romanna [79]

Answer:

optical

Explanation:

The earliest of these was the magnetic device. Computer systems began with magnetic storage in the form of tapes (yes, just like a cassette or video tape). These graduated to the hard disk drive and then to a floppy disk.

5 0
3 years ago
Other questions:
  • The Internet of Things (IoT) is a concept with emphasis on machine-to-machine communications to describe a more complex system t
    10·1 answer
  • The network topology in which each device is connected directly to a central network switch
    9·1 answer
  • Forms open in _______, which provides a user-friendly interface for entering data.
    11·1 answer
  • When you align or size a group of selected controls, the changes are made relative to the
    14·1 answer
  • You are adding a new 500 GB hard drive to your computer. The hard drive must be formatted with a file system to organize files i
    8·1 answer
  • Which of the following is NOT an argument used to determine how a shot is fired from an A. object the shot itself being instanti
    12·1 answer
  • In an information systems framework, ________ is the bridge between the computer side on the left and the human side on the righ
    14·1 answer
  • Which professionals can benefit from an understanding of statistics? Check all of the boxes that apply. magician trying to locat
    5·2 answers
  • second question today 25 POINTS: What is the formula to balance a lever when both effort and resistance are present?
    14·1 answer
  • Which example best demonstrates an impact of computers on the economy?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!