implement the above in c++, you will write a test program named
create_and_test_hash.cc . Your programs should run from the
terminal like so:
./create_and_test_hash <words file name> <query words file
name> <flag> <flag> should be “quadratic” for
quadratic probing, “linear” for linear probing, and “double” for
double hashing. For example, you can write on the terminal:
./create_and_test_hash words.txt query_words.txt quadratic You can
use the provided makefile in order to compile and test your code.
Resources have been posted on how to use makefiles. For double
hashing, the format will be slightly different, namely as
follows:
./create_and_test_hash words.txt query_words.txt double <R
VALUE> The R value should be used in your implementation of the
double hashing technique discussed in class and described in the
textbook: hash2 (x) = R – (x mod R). Q1. Part 1 (15 points) Modify
the code provided, for quadratic and linear probing and test
create_and_test_hash. Do NOT write any functionality inside the
main() function within create_and_test_hash.cc. Write all
functionality inside the testWrapperFunction() within that file. We
will be using our own main, directly calling
testWrapperFunction().This wrapper function is passed all the
command line arguments as you would normally have in a main. You
will print the values mentioned in part A above, followed by
queried words, whether they are found, and how many probes it took
to determine so. Exact deliverables and output format are described
at the end of the file. Q1. Part 2 (20 points) Write code to
implement double_hashing.h, and test using create_and_test_hash.
This will be a variation on quadratic probing. The difference will
lie in the function FindPos(), that has to now provide probes using
a different strategy. As the second hash function, use the one
discussed in class and found in the textbook hash2 (x) = R – (x mod
R). We will test your code with our own R values. Further, please
specify which R values you used for testing your program inside
your README. Remember to NOT have any functionality inside the
main() of create_and_test_hash.cc
You will print the current R value, the values mentioned in part A
above, followed by queried words, whether they are found, and how
many probes it took to determine so. Exact deliverables and output
format are described at the end of the file. Q1. Part 3 (35 points)
Now you are ready to implement a spell checker by using a linear or
quadratic or double hashing algorithm. Given a document, your
program should output all of the correctly spelled words, labeled
as such, and all of the misspelled words. For each misspelled word
you should provide a list of candidate corrections from the
dictionary, that can be formed by applying one of the following
rules to the misspelled word: a) Adding one character in any
possible position b) Removing one character from the word c)
Swapping adjacent characters in the word Your program should run as
follows: ./spell_check <document file> <dictionary
file>
You will be provided with a small document named
document1_short.txt, document_1.txt, and a dictionary file with
approximately 100k words named wordsEN.txt. As an example, your
spell checker should correct the following mistakes. comlete ->
complete (case a) deciasion -> decision (case b) lwa -> law
(case c)
Correct any word that does not exist in the dictionary file
provided, (even if it is correct in the English language). Some
hints: 1. Note that the dictionary we provide is a subset of the
actual English dictionary, as long as your spell check is logical
you will get the grade. For instance, the letter “i” is not in the
dictionary and the correction could be “in”, “if” or even “hi”.
This is an acceptable output. 2. Also, if “Editor’s” is corrected
to “editors” that is ok. (case B, remove character) 3. We suggest
all punctuation at the beginning and end be removed and for all
words convert the letters to lower case (for e.g. Hello! is
replaced with hello, before the spell checking itself).
Do NOT write any functionality inside the main() function within
spell_check.cc. Write all functionality inside the
testSpellingWrapper() within that file. We will be using our own
main, directly calling testSpellingWrapper(). This wrapper function
is passed all the command line arguments as you would normally have
in a main
In: Computer Science
C# Only
Create a class named Customer that implements IComparable interface.
Create 3 Customer class fields: Customer number, customer name, and amount due. Create automatic accessors for each field.
Create an Customer class constructor that takes parameters for all of the class fields and assigns the passed values through the accessors.
Create a default, no-argument Customer class constructor that will take no parameters and will cause default values of (9, "ZZZ", 0) to be sent to the 3-argument constructor.
Create an (override) Equals() method that determines two Customers are equal if they have the same Customer number.
Create an (override) GetHashCode() method that returns the Customer number.
Create an (override) ToString() method that returns a string containing the general Customer information (eg: CreditCustomer 1 russell AmountDue is $4,311.00 Interest rate is 0.01). Display the dollar amounts in currency format.
Implement CompareTo to compare object customer numbers for >, <, == to implement sorting for the array of objects.
Create a CreditCustomer class that derives from Customer and implements IComparable interface.
Create a class variable named Rate using an automatic accessor.
Create an CreditCustomer class constructor that takes parameters for the Customer class fields customer number, name, amount, and rate percent that sets the Rate CreditCustomer variable to the rate percentage. Pass the id number, name and amount back to the base Customer class constructor.
Create a default, no-argument CreditCustomer class constructor that will take no parameters and will cause default values of (0, "", 0, 0) to be sent to the 4-argument CreditCustomer constructor.
Create an (override) ToString() method that returns a string containing the general Customer information (eg: CreditCustomer 1 russell AmountDue is $4,311.00 Interest rate is 0.01 Monthly payment is $179.63). Display the dollar amounts in currency format.
Implement CompareTo to compare CreditCustomer objects based on customer numbers for >, <, == to implement sorting for the array of objects.
In Main:
Create an array of five CreditCustomer objects.
Prompt the user for values for each of the five Customer object; do NOT allow duplicate Customer numbers and force the user to reenter the Customer when a duplicate Customer number is entered.
CreditCustomer objects should be sorted by Customer number before they are displayed.
When the five valid Customers have been entered, display them all, display a total amount due for all Customers, display the same information again with the monthly payment for each customer. See the input/output example shown below.
Create a static GetPaymentAmounts method that will have the current Credit customer object as a parameter and returns a double value type. Each CreditCustomer monthly payment will be 1/24 of the balance (amount due). The computed monthly individual customer payment will be returned for each CreditCustomer object in the object array.
Internal Documentation.
Note that you will be overriding three object methods in the Customer class and one in the CreditCustomer class. Don't forget about IComparable.
An example of program output might look like this:
Enter customer number 3
Enter name johnson
Enter amount due 1244.50
Enter interest rate .10
Enter customer number 2
Enter name jensen
Enter amount due 543.21
Enter interest rate .15
Enter customer number 2
Sorry, the customer number 2 is a duplicate.
Please reenter 5
Enter name swenson
Enter amount due 6454.00
Enter interest rate .11
Enter customer number 1
Enter name olson
Enter amount due 435.44
Enter interest rate .20
Enter customer number 4
Enter name olafson
Enter amount due 583.88
Enter interest rate .25
Summary:
CreditCustomer 1 olson AmountDue is $435.44 Interest rate is
0.2
CreditCustomer 2 jensen AmountDue is $543.21 Interest rate is
0.15
CreditCustomer 3 johnson AmountDue is $1,244.50 Interest rate is
0.1
CreditCustomer 4 olafson AmountDue is $583.88 Interest rate is
0.25
CreditCustomer 5 swenson AmountDue is $6,454.00 Interest rate is
0.11
AmountDue for all Customers is $9,261.03
Payment Information:
CreditCustomer 1 olson AmountDue is $435.44 Interest rate is
0.2
Monthly payment is $18.14
CreditCustomer 2 jensen AmountDue is $543.21 Interest rate is
0.15
Monthly payment is $22.63
CreditCustomer 3 johnson AmountDue is $1,244.50 Interest rate is
0.1
Monthly payment is $51.85
CreditCustomer 4 olafson AmountDue is $583.88 Interest rate is
0.25
Monthly payment is $24.33
CreditCustomer 5 swenson AmountDue is $6,454.00 Interest rate is
0.11
Monthly payment is $268.92
Press any key to continue . . .
Declaring a child class:
public class Fiction : Book //for extending classes, you must
use a single colon between the derived class name and its base
class name
{
private:
//put your private data members here!
public:
//put your public methods here!
}
NOTE: when you instantiate an object of Fiction child class, you
will inherit all the data members and methods of the Book
class
In: Computer Science
The following questions are to be done in JAVA.
1) If an array is not considered circular, the text suggests that each remove operation must shift down every remaining element of the queue. An alternative method is to postpone shifting until rear equals the last index of the array. When that situation occurs and an attempt is made to insert an element into the queue, the entire queue is shifted down so that the first element of the queue is in the first position of the array. What are the advantages of this method over performing a shift at each remove operation? What are the disadvantages?
2) what does the following code fragment do to the queue q?
ObjectStack s = new ObjuectStack();
while (!q.isEmpty())
s.push(q.remove());
while (!s.isEmpty())
q.insert(s.pop());
3)Describe how you might implement a queue using two stacks. Hint: If you push elements onto a stack and then pop them all, they appear in reverse order. If you repeat this process, they're now back in order.
Thank you for all the help.
In: Computer Science
The college IT department manager no longer wants to use spreadsheets to calculate grades. The manager has asked you to create a program that will input the teachers' files and output the students' grades.
Write a Ruby program named format file.rb, which can be run by typing ruby widgets.rb.
In your Ruby environment, the program must read an input file formatted in CSV format, named input.csv. Each record contains data about a student and their corresponding grades.
The data will look similar to the following:
Student Name, assignment 1, assignment 2, assignment 3, assignment 4
John Adams, 90, 91, 99, 98
Paul Newman, 90, 92, 93, 94
Mary Smith, 95, 96, 99
Be careful to follow the output format exactly, including spacing. The output of your program must look like the following:
Student Assignment Average
John Adams 94.5
In: Computer Science
THIS IS IN PYTHON 3.0
Let's call the first function power(a,b). Use the built-in power function a**b in python to write a second function called testing(c) that tests if the first function is working or not.
I already have the function power(a,b), which is as follows:
def power(a, b):
if (b == 0): return 1
elif (int(b % 2) == 0):
return (power(a, int(b / 2)) *
power(a, int(b / 2)))
else:
return (a * power(a, int(a / 2)) *
power(a, int(b / 2)))
In: Computer Science
C programming
Program must use FileIO to read in a file formatted like below and print it to the screen;
#include<stdio.h>
#include<stdio.h>
int main)int argc, char * argv[])
{
printf("hello\n");
return 0;
}
it then must check if there are balanced Parentheses and balanced brackets.
If it is balanced it must display "Code is balanced" and if its not balanced it must display "code is not balanced"
In: Computer Science
Just have a quick question about IT in general. If there are any good study techniques/websites/youtube videos that can help explain how to use Python on a Macbook, I could really use the help. I'm currently running OSX 10.10.5 on my Mac, and am using the Python Crash Course book by Eric Matthes to reference.
In: Computer Science
Debate has emerged and raged on regarding many African countries
including Ghana not making rapid economic progress in an emerging
knowledge economy. Poverty exists in spite of development being
driven by technology, fuelled by information and powered by
knowledge, and, many are oblivious to the reality that information
and communication technology (ICT) cuts across all aspects of our
lives.
We take a queue from the ICT driven economic experiences of the
United States during the dot com boom and developments in Finland
and other Western economies. We are informed by issues of
globalization, the knowledge economy and the transformation of
business processes using ICT in India, China, Korea and Malaysia.
Close to us in Africa we are encouraged by economic growth using
ICT in Rwanda and South Africa.
Pundits have argued that illiteracy is to be blamed, and
mathematics and science education needs to be prioritized. Others
say it is in our attitude fashioned by our past which does not
relate development as an independent variable relative to other
variables such as technology. While some view our challenges as
lack of leadership to implement sustainable ICT policies and
strategies at a macro and micro level, many argue that development
of a nation’s economy has much to do with input from ICT personnel.
They do not only belong to the domain of personnel with tacit
knowledge of engineers who should provide infrastructure but such
need to study policies that determine development
a.
i. As a person in charge of IT in a government department in Ghana,
what indicators will you use to convince your colleagues that there
was a need to take steps to usher this country quickly into a
knowledge economy?
ii. What software option will you recommend to your ministry? Open
source or Microsoft as proprietary software? Provide reasons for
your recommendation.
iii. List FIVE (5) ways of how the TPS can be of use to a
government department.
b.
i. What challenges are government organizations likely to face in
deploying ICT to change their operations?
ii. Which communication medium would you recommend for a government
department, a cable, wireless or something else? Justify your
recommendation
In: Computer Science
Please use python.
Step a: Create two dataframes df1 and df2 as follows:
|
import numpy as np import pandas as pd rng = np.random.RandomState(100) df1 = pd.DataFrame(rng.randint(0, 100, (4, 3)), columns=['A', 'B', 'C']) df2 = pd.DataFrame(rng.randint(0, 100, (3, 4)), columns=['A', 'B', 'C', 'D']) |
Step b: Create a new dataframe df which is the summation of df1 and df2;
Step c: Subtract all columns of df by the half of column 'C' in df1; (Remark: the values in df should be updated)
Step d: Replace the NaN in df by 10; (Remark: the values in df should be updated)
Step e: Use df.apply() to calculate the summation of the numbers in each row of df, and show the result. (Remark: the result should be a vector of four values)
In: Computer Science
prove or disprove these three interval greedy algorithm underneath if it is an optimal greedy strategy.
(a) earliest finish time first
(b) shortest interval first
(c) fewest conflicts first
In: Computer Science
Windows monitoring tools are essential to the Windows Systems Administrator. Three software tools that are essential are: Task Manager, Event Viewer and Resource Monitor. Create a short PPT presentation of at least six slides (or more) for a 15-minute Windows Administrators Lunch and Learn session on the use of these three tools using the following requirements:
1) A slide with the description of each tool (one slide per tool)
2) Show how to measure CPU, Memory and Network Activity in Task Manager
3) Demonstrate how to find different events of different severities in Event Viewer.
4) Discuss the four elements of Resource Monitor – CPU, Disk, Network and Memory and how it can be used in real time and to review historical logs.
In: Computer Science
Write a java program, creating three threads, to sort two arrays and merge them into a third array. More specifically:
Create a thread to sort the first array. Create a thread to sort the second array. Create a thread to merge the arrays into the third array. Let the main method prints the merged array.
i want three threads to be created .
You must call the two sorter threads together. In other words, if we name these threads sorta, sortb, and merge, you must call the start methods in the following sequence: sorta.start(); sortb.start(); Some java code merge.start();
I post the sequential program for this assignment. Note that you need to change the classes Sorter and Merger to make them suitable for threads.
import java.util.Random;
public class Main{
public static void main(String[] args) {
Random rand = new Random();
int size = rand.nextInt(50) + 1;
int a[] = new int[size];
size = rand.nextInt(50) + 1;
int b[] = new int[size];
for(int i = 0; i < a.length; i++)
a[i] = rand.nextInt(999);
for(int i = 0; i < b.length; i++)
b[i] = rand.nextInt(999);
new Sorter(a);
new Sorter(b);
int[] c = new int[a.length + b.length];
new Merger(a, b, c);
for(int i = 0; i < c.length; i++)
System.out.print(c[i] + " ");
}
}
-------------------------------------------------------------------
public class Merger{
public Merger(int[]a, int[] b, int[] c){
merge(a, b, c);
}
private void merge(int[] a, int[] b, int[] c){
int index = 0, i = 0, j = 0;
while(i < a.length && j < b.length)
if(a[i] < b[j])
c[index++] = a[i++];
else
c[index++] = b[j++];
if(i < a.length)
for(int k = i; i < a.length; i++)
c[index++] = a[i];
if(j < b.length)
for(int k = j; j < b.length; j++)
c[index++] = b[j];
}
}
----------------------------------------------------------------------------------------------------------------
public class Sorter{
public Sorter(int[] a){
sort(a);
}
private void sort(int[] a){
for(int i = 0; i < a.length; i++){
int pos = i;
int min = a[i];
for (int j = i + 1; j < a.length; j++)
if(a[j] < min){
min = a[j];
pos = j;
}
a[pos] = a[i];
a[i] = min;
}
}
}
In: Computer Science
In: Computer Science
PLEASE ANSWER using R studio .
VARIABLE ASSIGNMENT AND SIMPLE FUNCTIONS ##
#########################################################
#Section 2 instructions:
#Answer the following questions by defining the provided
objects.
#Question 2.1 (2 points)
#Create a numeric vector that contains all integers between 1 and
1,000 (inclusive)
aS2Q1 <-
#Question 2.2 (2 points)
#Create a numeric vector that contains all even integers between 2
and 1,000 (inclusive)
aS2Q2 <-
#Question 2.3 (2 points)
#Four strings are defined as character vectors below. Using the
already defined
#character vectors, create a single character vector that combines
all of them
#and separates the contents of each with a comma followed by a
space.
str1 <- "The National Mall in Washington"
str2 <- "D.C. has monuments"
str3 <- "museums"
str4 <- "and scenery that draws many tourists from around the
world."
aS2Q3 <-
#Question 2.4 (2 points)
#Translate the following mathematical function into an R function
named "zFunction": z = (x + x^2 + x^3) - (y + y^2 + y^3)
#Then, evaluate for (x, y) = (3, 4) and save your answer to the
provided object.
zFunction <-
aS2Q4 <-
#Question 2.5 (2 points)
#Create a four-element list where each element is your answer to
questions 2.1-2.4.
#Name the four elements ans1, ans2, ans3, and ans4
aS2Q5 <-
#Question 2.6 (2 points)
#Display the element ans3 from the list created in question 2.5
using two different methods
In: Computer Science
The assignment will be graded both running and reading your code.
Readability: Your code should be readable. Add
comments wherever is necessary.
If needed, write helper functions to break the code into small,
readable chunks.
Write two concrete classes implementing GeometricShape
The class Circle. Circle will have the following public methods:
// a constructor
Circle(Point center, int radius);
// returns the area of the circle
float getArea();
// returns the perimeter of the circle
float getPerimeter();
// prints the center of the circle and its radius
virtual void print();
The class Rectangle. Rectangle will have the following public methods:
// a constructor
Rectangle(Point topLeftPoint, int length,
int width);
// returns the area of the rectangle
float getArea();
// returns the perimeter of the circle
float getPerimeter();
// prints the top left point of the rectangle, its length
and width
virtual void print();
Write a function test() that tests your solutions.
In: Computer Science