Questions
Language: C++ Conduct an evaluation of the performance of STL containers (vector, list, set, unordered_set) in...

Language: C++

Conduct an evaluation of the performance of STL containers (vector, list, set, unordered_set) in inserting and finding elements, with a relatively large data set. What you'll be measuring is the execution time. Obviously it's dependent on the speed of the computer one uses, so what matters is the relative speed (relative to the vector's speed in percentage)

  1. create a vector of 100,000 elements of integers, with the values initially set as 1~100,000, in this order.
  2. randomize the ordering of these values so they are shuffled
  3. measure the time of inserting all elements of this vector into another empty vector, list, set, and unordered_set, at the end of the container
    • that is, the time of populating 100K numbers in the 4 containers, respectively (4 resultant time durations)
    • you can write a universal function that does inserting at the iterator position returned by c.end(), where c is the container in question
  4. do the same for the 4 containers (also from the empty state), but inserting elements at the beginning of the container (inserting at .begin())
  5. with all containers properly populated, measure the time to find each value of (1~10,000, that's 10K) in vector, list, set, and unordered_set
    • that is, the time of finding all 10K numbers in the 4 containers, respectively (4 resultant time durations)
    • for vector/list, use the std::find() algorithm; for set/unordered_set, use the member function .find()
  6. when reporting your results, please also output the percentage relative to data for the vector

In: Computer Science

Create a c++ program that: Create an input file using notepad ( .txt ). When testing...

Create a c++ program that:

  1. Create an input file using notepad ( .txt ). When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors.
  2. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File” marker.
  3. Input date file consists of scores (one per line), might contain no score at all (an empty file) and program does not know how many scores before execution.
  4. If file not empty, determine how many valid scores (0 to 100), and how many invalid scores (less than 0 or greater than 100).
  5. Take only the valid scores and determine what letter grade and keep track of how many As, Bs, Cs, Ds, and Fs.  

(90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, 0 to 60 is a F)

  1. Output to the screen (not file output) with the followings: the number of valid scores, the number of invalid scores, the highest valid score, the lowest valid score, and the average of the valid scores. Also print out the histogram of the grades (sideway). Look at my output examples
  2. If the file is empty, don’t print any statistics at all. If the input file only has invalid scores, just print how many invalid scores and no valid scores, don’t include any statistics.
  3. Test your program with difference cases/scenarios.

In: Computer Science

Use Java (Science: day of the week) Zeller’s congruence is an algorithm developed by Christian Zeller...

Use Java

(Science: day of the week)

Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week.
The formula is :

h = (q + 26(m+1)/10 + k + k/4 + j/4 + 5j) % 7

where

- h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday).

- q is the day of the month.

- m is the month (3: March, 4: April, ..., 12: December). January and February are counted as months 13 and 14 of the previous year.

- j is the century (i.e., year/100)

- k is the year of the century (i.e., year%100).

Note that the division in the formula performs an integer division.

Write a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the week.

Sample Run 1

Enter year: (e.g., 2012): 2015
Enter month: 1-12: 1
Enter the day of the month: 1-31: 25
Day of the week is Sunday

Sample Run 2

Enter year: (e.g., 2012): 2012
Enter month: 1-12: 5
Enter the day of the month: 1-31: 12
Day of the week is Saturday

Sample Run 3

Enter year: (e.g., 2012): 2002
Enter month: 1-12: 3
Enter the day of the month: 1-31: 26
Day of the week is Tuesday

Sample Run 4

Enter year: (e.g., 2012): 2008
Enter month: 1-12: 1
Enter the day of the month: 1-31: 1
Day of the week is Tuesday

Sample Run 5

Enter year: (e.g., 2012): 2000
Enter month: 1-12: 2
Enter the day of the month: 1-31: 12
Day of the week is Saturday

(Hint: January and February are counted as 13 and 14 in the formula, so you need to convert the user input 1 to 13 and 2 to 14 for the month and change the year to the previous year.)

Class Name: Exercise03_21

If you get a logical or runtime error, please refer https://liveexample.pearsoncmg.com/faq.html.

In: Computer Science

#include <iostream> #include <string> #include <fstream> #include <vector> #include <sstream> using namespace std; int main() {...

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
int main()
{
ifstream infile("worldpop.txt");
vector<pair<string, int>> population_directory;
string line;
while(getline(infile, line)){
if(line.size()>0){
stringstream ss(line);
string country;
int population;
ss>>country;
ss>>population;
population_directory.push_back(make_pair(country, population));
}
}
cout<<"Task 1"<<endl;
cout<<"Names of countries with population>=1000,000,000"<<endl;
for(int i=0;i<population_directory.size();i++){
if(population_directory[i].second>=1000000000){
cout<<population_directory[i].first<<endl;
}
}
cout<<"Names of countries with population<=1000,000"<<endl;
for(int i=0;i<population_directory.size();i++){
if(population_directory[i].second<=1000000){
cout<<population_directory[i].first<<endl;
}
}
}

can u pls explain the logic behind this code up to 10 lines pls, many thanks

In: Computer Science

1. Make the flow diagram and the C ++ program that receives three integer values ​​R,...

1. Make the flow diagram and the C ++ program that receives three integer values ​​R, T and Q, determine if they satisfy the expression below, and if so, show the corresponding values ​​of R, T and Q. R'- T '+ 4 * Q? <820

2. Construct a flow chart and the corresponding program in C which, when receiving Y as data, calculates the result of the following function and prints the values ​​of X and Y.

In: Computer Science

Write a python code to Design and implement a function with no input parameter which reads...

Write a python code to Design and implement a function with no input parameter which reads a number from input (like 123). Only non-decimal numbers are valid (floating points are not valid). The number entered by the user should not be divisible by 10 and if the user enters a number that is divisible by 10 (like 560), it is considered invalid and the application should keep asking until the user enters a valid input. Once the user enters a valid input, the program calculates the reverse of the input number (for 153, the reverse is 351) and prints the result and returns the results.Do not use try and except. Use Main function.

In: Computer Science

Question 4 A connection between two or more computers on the same network connected via a...

Question 4

A connection between two or more computers on the same network connected via a cable and two computers in different parts of the world differs. Identify explain how the two connections types differ. Suppose that you are required to create a document to explain the different sections of DTE and DCE, by indicating the purpose of NIU and NID. Where would a wireless base station connect to a cellular network?

In: Computer Science

Write a C++ program in a file called pop.cpp that opens a file called pop.dat which...

Write a C++ program in a file called pop.cpp that opens a file called pop.dat which has the following data (you’ll have to create pop.dat)

AX013 1.0

BX123456 1234.56

ABNB9876152345 99999.99

The data are account numbers and balances. Account numbers are, at most 14 characters. Balances are, at most, 8 characters (no more than 99999.99). Using a loop until the end of file, read an account number and balance then write these to standard output in the following format shown below. Use the I/O manipulators setw, left, and right. Set the precision/fixed/showpoint so that all numeric data is written are written with exactly two digits to the right of the decimal.

Account Number    Balance

-------------------------

AX013          $     1.00

BX123456       $ 1234.56

ABNB9876152345 $ 99999.99

In: Computer Science

Use Java (Find the number of days in a month) Write a program that prompts the...

Use Java

(Find the number of days in a month)

Write a program that prompts the user to enter the month and year and displays the number of days in the month.

For example,

If the user entered month 2 and year 2012, the program should display that February 2012 has 29 days.

If the user entered month 3 and year 2015, the program should display that March 2015 has 31 days.

Sample Run 1

Enter a month in the year (e.g., 1 for Jan): 2
Enter a year: 2012
February 2012 has 29 days

Sample Run 2

Enter a month in the year (e.g., 1 for Jan): 4
Enter a year: 2005
April 2005 has 30 days

Sample Run 3

Enter a month in the year (e.g., 1 for Jan): 2
Enter a year: 2006
February 2006 has 28 days

Sample Run 4

Enter a month in the year (e.g., 1 for Jan): 2
Enter a year: 2000
February 2000 has 29 days

Class Name: Exercise03_11

If you get a logical or runtime error, please refer https://liveexample.pearsoncmg.com/faq.html.

In: Computer Science

Match the following column A column B Comment. 1. java.util.Scanner Wrapper 2. length char[] myletters 3....

Match the following

column A column B

Comment. 1. java.util.Scanner

Wrapper 2. length

char[] myletters 3. final int x=10;

import java.io.* 4. catch

ArrayList 5.alpha

String Class 6.double

Switch 7.inputfile.close();

try 8.remove()

Constant 9.default

Keyboard Input 10.compare

In: Computer Science

Why QoS in mobile networks should be considered on an end to end basis? and how...

Why QoS in mobile networks should be considered on an end to end basis? and how does jitter affect QoS in mobile networks?

In: Computer Science

Given two arrays: A[0..m-1] and B[0..n-1]. Find whether B[] is a subset of A[] or not....

Given two arrays: A[0..m-1] and B[0..n-1]. Find whether B[] is a subset of A[] or not. Both the arrays are not in sorted order. It may be assumed that elements in both array are distinct. Design an O(n) time algorithm that solves this problem. Provide pseudocode

Ex:
Input: A[] = {11, 1, 13, 21, 3, 7}, B[] = {11, 3, 7, 1}
Output: B[] is a subset of A[]

Input: A[] = {1, 2, 3, 4, 5, 6}, B[] = {1, 2, 4}
Output: B[] is a subset of A[]

Input: A[] = {10, 5, 2, 23, 19}, B[] = {19, 5, 3}
Output: B[] is not a subset of A[]

In: Computer Science

Language: Java Crust : A small pizza costs $5.99, a medium is $7.99, and a large...

Language: Java

Crust :

A small pizza costs $5.99, a medium is $7.99, and a large is $9.99.

A handtossed crust is an additional $0.50, and a deep dish pan crust is an additional $1.00.

Do a CrustSize enum [S(5.99), M(7.99), and L(9.99)] and a CrustType enum [THIN(0.00), HAND(0.50), and PAN(1.00)].

Place your enums in CrustEnum.java.

Both enums should have cost methods.

Do a Crust class with a constructor that accepts and sets the crust size and type, and provide a crustCost method.

Do a toString method to report the state of the crust.

Write getCrust (returns "THIN", "HAND", or "PAN") and getSize (returns a char 'S', 'M', or 'L').

I have most of it already, I just need help with the Crust class, aka the crustCost, toString, and getCrust.

There is a toString method, though I dont know if its right, as well as a crustCost.

If you need to delete something because it is wrong, feel free.

CrustEnum.java:

public enum CrustSize{
   S(5.99),
   M(7.99),
   L(9.99);

   private double cost;
  
   private CrustSize(double cost){
       this.cost = cost;
   }
  
   public double getCost(){
       return this.cost;
  
}

public enum CrustType{
   THIN(0.00),
   HAND(0.50),
   PAN(1.00);
  
   private double cost;
  
   CrustType(double cost){
       this.cost = cost;
      
   }
   public double getCost(){
       return this.cost;
   }
}

private CrustSize size;
private CrustType type;

public CrustEnum(String size, String type){
   this.size = CrustSize.valueOf(size);
   this.type = CrustType.valueOf(type);
}

public double CrustCost(){
   return (size.getCost() + type.getCost());
}
}

public class Crust {
   private CrustEnum crust;
  
   public Crust(String size, String type){
       this.crust = new CrustEnum(size,type);
   }
  
   public String toString(){
       return "The crust is a " + this.size + " " + this.type + " pizza";
  
   public double crustCost(){
       return crust.crustCost();
   }
}

In: Computer Science

Use Java (Algebra: solve 2 x 2 linear equations) A linear equation can be solved using...

Use Java

(Algebra: solve 2 x 2 linear equations)

A linear equation can be solved using Cramer’s rule given in Programming Exercise 1.13.

Write a program that prompts the user to enter a, b, c, d, e, and f and displays the result.

If ad - bc is 0, report The equation has no solution.

Sample Run 1

Enter a, b, c, d, e, f: 9.0 4.0 3.0 -5.0 -6.0 -21.0
x is -2.0 and y is 3.0

Sample Run 2

Enter a, b, c, d, e, f: 1.0 2.0 2.0 4.0 4.0 5.0
The equation has no solution

Sample Run 3

Enter a, b, c, d, e, f: 1.0 2.0 2.0 4.0 4.0 5.0 6.0

x is -4.0 and y is 4.5


Class Name: Exercise03_03

If you get a logical or runtime error, please refer https://liveexample.pearsoncmg.com/faq.html.

In: Computer Science

Consider distributing a file of F = X Gbits to N = 20 peers. The server...

Consider distributing a file of F = X Gbits to N = 20 peers. The server has an upload rate of us = X*3 Mbps, and each peer has a download rate of di = X/2 Mbps and an upload rate of X/10.

The numeric value X is the position of the first letter of your last name in the alphabet. For example if your last name starts with A then X = 1 and F = 1 Gbits.

Find the distribution time for
1. Client-server distribution
2. Peer-to-peer distribution

In: Computer Science