how to write a genetic algorithm for a knapsack problem .
In: Computer Science
You are tasked with developing an application that
converts US currency ($) to 3 other major world
currencies.
Here are the current rates:
1 US dollar = 0.90 EURO
1 US dollar = 107.7 Japanese YEN
1 US dollar =19.45 Mexican PESO
Your application must prompt the user to enter an
amount in US dollars, convert it into EURO, YES, and PESO and then
display all using a suitable format.
Coding requirements:
-All your variables MUST declared inside main()
except for the Scanner.
-Code function(s)/method(s) that handle
all input.
-Code function(s)/method(s) that handles all
conversions.
-Code a function/method that displays the result of
the conversion. Your output must be clear and well
labeled.
(show the amount input in dollar, then show the amount
of the conversion for each of the three major currencies)
In: Computer Science
Complete the Vec class to make it similar to the vector.
sample code here.
#include
#include
#include
#include
#include
using namespace std;
int get_mode( vector vec )
{
int numbers[101] = {0};
for ( int e : vec ) numbers[e]++;
int greatest = 0, n = 0;
for ( int i = 0; i <= 100; i++ )
{
if ( numbers[i] > greatest )
{
greatest = numbers[i];
n = i;
}
}
return n;
}
const double g = 9.81;
const double k = 0.24;
double v( double m, double t )
{
return sqrt(m * g / k) * tanh( sqrt(k * g / m) * t );
}
double d( double m, double t )
{
return m / k * log( cosh(sqrt(k * g / m) * t) );
}
int main()
{
cout << "Please enter the skydiver mass: ";
double m;
cin >> m;
cout << "k = 0.24kg/m, m = 95.0kg, g = 9.81m/s^2" << endl;
cout << endl;
cout << "| Time | Velocity | Distance |" << endl;
for ( int t = 1; t <= 8; t++ )
{
cout << "| " << setw(4) << t << " | ";
cout << setw(8) << fixed << setprecision(2) << v(m, t) << " | ";
cout << setw(8) << fixed << setprecision(2) << d(m, t) << " |" << endl;
}
return 0;
}
In: Computer Science
-create a magic 8 ball program in Javascript.
-use a loop to ask for the question
-use a random number to get the answer let randAnswer =
Math.round(Math.random()*10);
-must have at least10 different answers
-must use elseif or switch statement
-must outputs both answers and user to input the console
-program should repeat indefinitely until either blank input or
cancel is selected
In: Computer Science
Make a function in Python that can do the following:
Longest Increasing Sub-sequence:
The input is a sequence of numbers and the goal is to find a subsequence of the given sequence in which the subsequence's elements are in increasing order. You are looking for the longest possible such subsequence.
In: Computer Science
L4 (0.4 marks) Code a calling and called method that tries to demonstrate that a called method cannot remember how many times it has been called if it’s limited to only using its formal parameters and local variables. For technical reasons this cannot be demonstrated. You will discover why in your attempt. Now use a class-level variable to do the job properly.
In: Computer Science
Please use markup language HTML5 please.
For this homework assignment, you will create a Web site made up of three different pages and links between those pages
Index.htm
Content.htm
For this page, you have considerable flexibility. You can use any content that you want. Pick a subject in which you are interested, and teach me something or inform me about it. You do not need to write all of the content yourself. You can cut and paste it from the Web.
To get full credit, your page MUST meet the following minimum requirements.
Copyright.htm
In: Computer Science
- List the benefits of deploying Windows Server Update Services in the network
- Define the new features In the latest version of Windows Server Update Services
In: Computer Science
Write an advertisement for a user support position. Find one or
more ads online or in
your local newspaper for information technology and user support
positions. Note the format
and content of a typical help wanted ad in the IT field. Select one
of the user support position
descriptions in Chapter 1, and then write a classified ad that
could be used to attract job
applicants for the position whose description you selected.
In: Computer Science
In: Computer Science
can you give me a brief description of your experience related to each of these bullets?
In: Computer Science
Programming language: JAVA
First, implement a recursive, Divide&Conquer-based algorithm to identify both the Minimum and Maximum element in an unsorted list.
Second, convert your recursive algorithm to a non-recursive (or iterative) implementation. For your input, populate an "unsorted list" with random elements between 1 and 1,000,000.
In: Computer Science
Demonstrate your grasp of the Unix file system by constructing a directory structure as follows:
In your home ( ~ ) directory, create a directory named “UnixCourse”.
This directory will be used in the remaining assignments of this course, as well as this one.
Several of the commands that you will issue in this course will examine files in this directory and, in some cases, send me a listing of those files or even copies of those files for grading and diagnostic purposes. So you should not store anything unrelated to the course assignments in this ~/UnixCourse area.
Within your UnixCourse directory, you should create a directory named “fileAsst”. Within that directory, you should create two directories, named “Empire” and “Alliance”.
Use the ls command to check your work.
Within the Empire directory, you should place a copy of the file ~cs252/Assignments/fileAsst/darth.txt
Use the ls command to check your work.
Within the Alliance directory, you should place a copy of the file ~cs252/Assignments/fileAsst/r2d2.txt
Use the ls command to check your work.
When you have completed this much, execute the command
~cs252/bin/fileAsst-1
(Take note of the difference between the numeric digit 1 and the lower-case letter l in the command above. If you can’t tell the difference between these, check your web browser settings to see if you can get it to use some better fonts.)
This will check to see if you have built the desired directory structure so far. You should repeat the above steps as necessary until this command reports success.
If you have been successful so far, the fileAsst-1 command will have placed a new file somewhere in the directory structure you have built. Find it, and move it into the Empire directory, renaming the file to “emperor.dat”.
Execute the command
~cs252/bin/fileAsst-2
If all is well, you will receive the access code for completion of this assignment.
In: Computer Science
What are the the three characteristics of Big Data, and what are the main considerations in processing Big Data?
In: Computer Science
Your primary task for this exercise is to complete header file by writing three functions with its description below:
removeAt function – to remove the item from the list at the position specified by location. Because the list elements are in no particular order (unsorted list), you could simple remove the element by swapping the last element of the list with the item to be removed and reducing the length of the list.
insertAt function - to insert an item in the list at the position specified by location. The item to be inserted is passed as a parameter to the function.
print function – to output the elements of the list.
3. Demonstrate the program by asking a user to enter 5 integers. After displaying 5 integers, ask the user the position of the item to be deleted. You can use your own data to generate two outputs.
Sample output 1:
Enter 5 integers: 45 19 2 16 77
The list you entered is: 45 19 2 16 77
Enter the position of item to be deleted: 2
After removing element at 2, the list is:
45 19 77 16
Sample output 2:
Enter 5 integers: 15 12 11 3 49
The list you entered is: 15 12 11 3 49
Enter the position of item to be deleted: 6
The location of the item to be removed is out of range
After removing element at 6, the list is:
15 12 11 3 49
======================================== C++
#ifndef H_arrayListType #define H_arrayListType #include <iostream> #include <cassert> using namespace std; template <class elemType> class arrayListType { public: const arrayListType<elemType>& operator= (const arrayListType<elemType>&); //Overloads the assignment operator void print() const; //Function to output the elements of the list //Postcondition: Elements of the list are output on the // standard output device. void insertAt(int location, const elemType& insertItem); //Function to insert an item in the list at the //position specified by location. The item to be inserted //is passed as a parameter to the function. //Postcondition: Starting at location, the elements of the // list are shifted down, list[location] = insertItem;, // and length++;. If the list is full or location is // out of range, an appropriate message is displayed. void removeAt(int location); //Function to remove the item from the list at the //position specified by location //Postcondition: The list element at list[location] is removed // and length is decremented by 1. If location is out of // range,an appropriate message is displayed. arrayListType(int size = 100); //constructor //Creates an array of the size specified by the //parameter size. The default array size is 100. //Postcondition: The list points to the array, length = 0, // and maxSize = size arrayListType(const arrayListType<elemType>& otherList); //copy constructor ~arrayListType(); //destructor protected: elemType *list; //array to hold the list elements int length; //to store the length of the list int maxSize; //to store the maximum size of the list }; // print function definition template <class elemType> void arrayListType<elemType>::print() const { // your code here } // insertAt function definition template <class elemType> void arrayListType<elemType>::insertAt (int location, const elemType& insertItem) { // your code here } //end insertAt // removeAt function definition template <class elemType> void arrayListType<elemType>::removeAt(int location) { // your code here } //end removeAt // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ template <class elemType> arrayListType<elemType>::arrayListType(int size) { if (size < 0) { cerr << "The array size must be positive. Creating " << "an array of size 100. " << endl; maxSize = 100; } else maxSize = size; length = 0; list = new elemType[maxSize]; assert(list != NULL); } template <class elemType> arrayListType<elemType>::~arrayListType() { delete [] list; } template <class elemType> arrayListType<elemType>::arrayListType (const arrayListType<elemType>& otherList) { maxSize = otherList.maxSize; length = otherList.length; list = new elemType[maxSize]; //create the array assert(list != NULL); //terminate if unable to allocate //memory space for (int j = 0; j < length; j++) //copy otherList list [j] = otherList.list[j]; } //end copy constructor template <class elemType> const arrayListType<elemType>& arrayListType<elemType>::operator= (const arrayListType<elemType>& otherList) { if (this != &otherList) //avoid self-assignment { delete [] list; maxSize = otherList.maxSize; length = otherList.length; list = new elemType[maxSize]; //create the array assert(list != NULL); //if unable to allocate memory //space, terminate the program for (int i = 0; i < length; i++) list[i] = otherList.list[i]; } return *this; } #endif
==================================================================
#include <iostream> #include "arrayListType.h" using namespace std; int main() { arrayListType<int> intList(100); int counter; int number; int position; cout << "Enter 5 integers: "; for (counter = 0; counter < 5; counter++) { cin >> number; intList.insertAt(counter, number); } cout << endl; cout << "The list you entered is: "; intList.print(); cout << endl; cout << "Enter the position of item to be deleted: "; cin >> position; intList.removeAt(position); cout << "After removing element at " << position << ", the list is:" << endl; intList.print(); system("pause"); return 0; } /* Enter 5 integers: 45 19 2 16 77 The list you entered is: 45 19 2 16 77 Enter the position of item to be deleted: 2 After removing element at 2, the list is: 45 19 77 16 */ /* Enter 5 integers: 15 12 11 3 49 The list you entered is: 15 12 11 3 49 Enter the position of item to be deleted: 6 The location of the item to be removed is out of range After removing element at 6, the list is: 15 12 11 3 49 */
In: Computer Science