1. A finite sequence of letters is called a palindrome if it reads the same forward or backward. Devise an algorithm for determining whether or not a string of n letters is a palindrome. Write your algorithm using the the same sort of pseudocode used in the text. Your algorithm should start with procedure palindrome (a1,a2,...,an: lowercase letters) Your procedure should return the value 0 if the string is a palindrome, and the first integer i such that ai 6=an−i+1 if the string is not a palindrome.
2. Show all steps taken by your algorithm if you input the string the string abcdba. What number does the procedure return?
3. Show all steps taken by your algorithm if you input the string the string azyza. What number does the procedure return?
In: Computer Science
#1 a. When to use an Interface vs when to use an abstract class. For each “when” provide extended example(s) (with class/interface codes). b. Suppose you have an interface Moveable. Think of some interface that can extend it. Implement this two interfaces. (java oop)-> laboratory work
In: Computer Science
In: Computer Science
As we move closer to choosing tools for data mining it is important to understand what you intend to do with a specific tool.
a. In your own words, describe why you would choose a tool to:
- Predict unknown or future value
- Describe with interesting, interpretable patterns
b. In your own words, briefly describe these data mining techniques:
- Regression (predictive)
- Association Rule Discover (descriptive)
- Classification (predictive)
- Clustering (descriptive)
In: Computer Science
Match each function type correctly.
Question 1 options:
|
|
In: Computer Science
C++ UNIX
car.txt
0001|Mercury|LeSabre|2005|Brown|11000|2019-09-01
0002|Chevrolet|Aveo|2013|Blue|12000|2019-09-02
0003|Datsun|240Z|1979|Orange|13000|2019-09-03
0004|Ford|Galaxie|1964|Black|14000|2019-09-04
0005|Porsche|Boxster|2014|Green|15000|2019-09-0
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
const int RECORDS = 42;
ifstream reader("car.txt");
if(!reader) {
cout << "Error: cannot open
input file" << endl;
return -1;
}
string item[RECORDS];
int i = 0;
while(!reader.eof()) {
if((i+1) % 7 == 0)
getline(reader,item[i++],'\n');
else
getline(reader,item[i++],'|');
}
i = 0;
while(i < RECORDS) {
cout << "(1) carID= "
<< item[i++] << endl;
cout << "(2) carManufacturer=
" << item[i++] << endl;
cout << "(3) carModel= "
<< item[i++] << endl;
cout << "(4) carYear= "
<< item[i++] << endl << endl;
cout << "(5) carColor= "
<< item[i++] << endl << endl;
cout << "(6) carPrice= "
<< item[i++] << endl << endl;
cout << "(7)
carInventoryDate= " << item[i++] << endl << endl;
}
reader.close();
return 0;
}
this is my code to read that text file.
and output should be
(1) carID=0001
(2) carManufacturer=Mercury
(3) carModel=LeSabre
(4) carYear=2005
(5) carColor=Brown
(6) carPrice=11000
(7) carInventoryDate=2019-09-01
and so on.
but my output is
(1) carID= 0001
(2) carManufacturer= Mercury
(3) carModel= LeSabre
(4) carYear= 2005
(5) carColor= Brown
(6) carPrice= 11000
(7) carInventoryDate= 2019-09-01
like this. I don't know why there is space between 4, 5, 6, 7
please help me to fix
Thank you
In: Computer Science
In: Computer Science
Programming in R
test1
[1] 62.21030 57.60602 86.21137 84.73354 83.74019 69.68914
84.57337 68.31329 74.84393 77.75101 69.23417 66.95640
[13] 68.56414 71.97554 63.92802 74.36488 72.45757 72.37171 72.23253
86.86378 91.33591 60.92220 94.63742 78.92828
[25] 85.36320 65.42284 77.67914 74.72229 66.06849 66.18031
test2
[1] 70.92537 61.84501 79.35110 66.56921 85.24835 71.78693
77.12057 82.20876 71.54209 66.11271 62.46592 79.36359
[13] 73.91162 77.18452 71.46808 72.78128 82.57056 78.34531 59.93903
64.00577 72.96255 75.81221 69.76166 68.04771
[25] 64.12077 84.65762 64.87694 80.51515 78.21864 79.27847
The two vectors above (test1 and test2) represent exam scores from two different classes of size 30 (taught by two different teachers). If one class is scoring significantly higher than the other, it could be interpreted that one teacher is more effective than the other.
a. Find the mean test score for each class. Which class did better, based on means? Would you say they did significantly better?
b. Create comparative (side-by-side) boxplots in R for the two classes. Based on these, do you believe one teacher is more effective than the other? Significantly more effective?
c. Create comparative density plots for the two small classes on the same set of axes (you can use par(new=TRUE)) and make sure xlim and ylim are the same). Based on these, do you believe one teacher is more effective than the other? Significantly more effective?
d. Perform a two-sample t-test (one-tailed) to see if there is a difference in the population means for the two classes. Based on these, do you believe one teacher is more effective than the other? Significantly more effective? Significant in what sense?
In: Computer Science
In: Computer Science
Do you think that UML can move into the next decade and still be relevant? If we think about the type of work being done and our increased dependence upon mobile apps and AI, can we count on UML?
In: Computer Science
In: Computer Science
An employment agency needs to convert its basic one-table management system into a modern information management system/database that can hold its improving business. You are hired to create this IMS and the first step you are carrying out is normalization. The table that the agency originally uses is the following:
APPLICATION(ApplicantName, AppicantPhone1, ApplicantPhone2, ApplicantAddress, ApplicantFieldOfInterest, ApplicanHighestLevelOfEducation, EmployerBusinessName, EmployerAddress, EmployerPhoneNumber, EmployerCity, EmployerEmail, JobPostingID, JobPostingTitle, JobYearlySalary, InterviewId, InterviewDate, NamesOfInterviewers, OfferDetailsIfApplicable)
Rules:
- Applicants can be identified by their phone number(s)
- No two employers can have the same name
- Employers can post more than 1 posting
- Applicant can apply for more than one posting
You are required to put the previous table in 4NF (step-by-step: 1NF, 2NF, 3NF and 4NF).
In: Computer Science
In: Computer Science
In: Computer Science
ALL IN PYTHON PLEASE
Problem 1: Accept one integer from the user and store that information in a variable called endNo. Use an IF structure to check that endNois a positive number. If endNo is negative, print an error message and stop. If it is positive, use a loop (for or while) to generate odd numbers from 1 to endNo. Calculate the sum of these numbers using an accumulator.
Rubric:
Data input and data type conversions: 2.5 pts
Use of IF structure to verify that endNo is positive: 2.5 pts
Use of loop to generate numbers from a (inclusive) to b (not
inclusive): 5 pts
Use of an accumulator (note: print the cumulative sum only once): 5
pts
Problem 2:
Modify problem 1 and allow the user to specify the (a) starting value for the loop, (b) stopping value for the loop, and (c) the step function. Please note that the stopping value must be included in the calculation of your running total. Example of the desired solution:
Enter starting value: 5
Enter stopping value: 15
Enter step value: 5
30
In the above example, the result (30) is the sum of 5 + 10 + 15.
Note that both the starting value and ending value are included in
the running total. The step value determines the series.
Rubric:
Modification of the loop function: 5 pts
Problem 3:
Define a VALUE-RETURNING function that accepts one parameter - an integer number. The function, which must be a value-returning function, returns 1 if the number is even or 0 if the number is odd. In the “main” function (i.e. def main()), capture the return value and print an appropriate message on screen (i.e. number is even or odd).
Rubric:
Correctly defined a value-returning function: 5 pts
Correctly capture and use return value from a value-returning function: 5 pts
Sample Output:
Enter n: 4
Even
Problem 4
Write a program to compute the area of a circle some 'n' times. You must accept n and r from the user. Area is calculated using (22/7.0)*r*r - where r is the radius. Implement using value-returning functions. Hint: create a function to calculate area taking r as a parameter. In the main() function, ask for n and create a loop where you input r and invoke the area function n times.
Rubric:
Correct use of a loop to perform n calculations for the user: 5
pts
Correct use of value-returning functions inside a loop structure:
10 pts
Sample Output:
Enter n: 3
Enter r: 34
Area is: 3633.14285714
Enter r: 23
Area is: 1662.57142857
Enter r: 43
Area is: 5811.1428571
In: Computer Science