Complete the following questions:
1. Apply the Horspool algorithm to determine the location of the pattern “BABOON” within the text: “KARL_SAW_THE_BABOON”.
2. Given the following input data: 50, 18, 62 55, 81, 77, 54, construct both the “open” and “closed” hash tables.
1. To implement the Horspool algorithm first a shift table need to be prepared. The shift table will define the number of shift need to be taken for each character of the string.
Here the pattern is, "BABOON"
No. of Character: 6
So the number of shift for the character of the pattern will be B = 5, A = 4, B = 3 (Overwrite the value 5), O = 2, O = 1 (Overwrite the value 2) and N will not be considered here.
The number of shift for the character of the string will be 6.
The final shift table is given below:
character c | A | B | E | H | K | L | N | O | R | S | T | W | _ |
shift t (c) | 4 | 3 | 6 | 6 | 6 | 6 | 6 | 1 | 6 | 6 | 6 | 6 | 6 |
Now the algorithm will start:
K | A | R | L | _ | S | A | W | _ | T | H | E | _ | B | A | B | O | O | N |
B | A | B | O | O | N |
N is not equal to S. So the pattern will be shifted by 6 characters (From the shift table for character S).
K | A | R | L | _ | S | A | W | _ | T | H | E | _ | B | A | B | O | O | N |
B | A | B | O | O | N |
N is not equal to E. So the pattern will be shifted by 6 characters (From the shift table for character E).
K | A | R | L | _ | S | A | W | _ | T | H | E | _ | B | A | B | O | O | N |
B | A | B | O | O | N |
N is not equal to O. So the pattern will be shifted by 1 character (From the shift table for character O).
K | A | R | L | _ | S | A | W | _ | T | H | E | _ | B | A | B | O | O | N |
B | A | B | O | O | N |
And the pattern finally matched. So the algorithm end.
2. To construct the open and close hash table a hash function H(K) = K mod n is needed. As the number of input is 7, let the hash function is H(K) = K mod 7.
Open Hash Table:
50 % 7 = 1
18 % 7 = 4
62 % 7 = 6
55 % 7 = 6
81 % 7 = 4
77 % 7 = 0
54 % 7 = 5
0 | 1 | 2 | 3 | 4 | 5 | 6 |
77 | 50 | 18 | 54 | 62 | ||
81 | 55 |
Closed Hash Table:
In a closed hash table if a collision (two data on the same position) occurs then the data will be shifted to the next empty cell.
As 55 should be in 6th cell, but there would be a collision so it would be shifted to 7th cell.
As 55 should be in 4th cell, but there would be a collision so it would be shifted to 5th cell.
As 54 should be in 45h cell, but there would be a collision so it would be shifted to 8th cell.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
77 | 50 | 18 | 81 | 62 | 55 | 54 |
Complete the following questions: 1. Apply the Horspool algorithm to determine the location of the pattern...
Complete the stemplot for the following data. 63 66 81 66 55 50 64 69 64 89 89 67 56 62 71 67 78 69 74 64 60 50 65 51 54 53 70 55 63 71 5 00134556 6 02334445667799 7 | 01148 8 8
Write a python nested for loop that prints out the following pattern 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33...
For each variable of interest, do the following: 1. Find the mean, five-number summary, range, variance, and standard deviation. Display these numbers in a format that is easy to understand. 2. For each variable of interest, use its five-number summary to construct a boxplot. Each boxplot must be constructed horizontally, and must be accompanied by a brief descriptive paragraph that assesses whether the data appear to be symmetrical, left-skewed, or right-skewed. Construct a 95% confidence interval for the mean μ...
Please help me answer the following questions: Consider the following example. In a study reported in the California Journal of Nursing, nurses were asked to report their degree of job-related stress. They were asked 15 questions about their work and they responded on a 1-5 scale as the amount of stress they felt. These responses were added up in order to come up with a numeric measure of job stress (15 being the minimum stress and 95 the maximum stress)....
Questions 14 and 15 refer to the following: Every day for a month, Amanda does the crossword puzzle in the local newspaper. The times (in minutes) she takes to complete the puzzle are ordered and shown below: 15 20 23 27 28 30 31 34 35 35 35 36 37 37 37 39 39 40 41 41 41 41 42 45 50 52 55 58 62 67 The five-number summary is calculated to be: 15 34 38 42 67 Question...
Problem 1: Confidence Interval for Percentage of B’s. The data set “STAT 250 Final Exam Scores” contains a random sample of 269 STAT 250 students’ final exam scores (maximum of 80) collected over the past two years. Answer the following questions using this data set. a) What proportion of students in our sample earned B’s on the final exam? A letter grade of B is obtained with a score of between 64 and 71 inclusive. Hint: You can do this...
please help
1. Consider the sample given below. Find the following information. 16 32 40 52 19 34 43 54 20 35 46 57 21 35 46 62 23 35 46 23 36 48 27 39 50 A. 1 B. Range = C. Midrange D. Mode = E. Class width if we wish to have 5 classes = F. How many numbers are strictly below 50? G. What percent of data are strictly below 50? H. Make a complete frequency...
please Answer question 9 and 10
Question 4 answer is : The distribution is not normally
distributed.
Question 6 answer is : 80%
Question 7 answer is : 92%
Question 8 answer is : 98%
Question: Using the computer (Excel), answer the following 10 questions: Assessing Normality Many times in statistics it is necessary to see if a set of data values is approximately normally dis- tributed. There are special techniques that can be used. One technique is to draw...
?
Geog140 Introduction to Weather Interpreting Fronts on a Surface Weather Map Name: The map (on the other side) contains coded weather station information for the central and eastern portion of the U.S. Recall the procedure for coding (or in this case, deciphering) weather station data and answer the following questions, annotate appropriately: 1. What is the highest temperature on the map? 2. What is the lowest temperature on the map? 3. What is the highest atmospheric pressure on the...
Written in Java Your job is to produce a program that sorts a list of numbers in ascending order. Your program will need to read-in, from a file, a list of integers – at which point you should allow the user an option to choose to sort the numbers in ascending order via one of the three Sorting algorithms that we have explored. Your program should use the concept of Polymorphism to provide this sorting feature. As output, you will...