Questions
Python: def factors(matrix, factor): The matrix is a 3D list of integers. factors are either one,...

Python:

def factors(matrix, factor):

The matrix is a 3D list of integers.

factors are either one, two, or three

If the factor is 'one' it will return a the first value from each list

if the factor is 'two' it will return the second value, and same for the third.

Example;

input = [ [ [1, 2, 3], [3, 2, 9], [9, 8, 6] ],

[ [0, 0, 4], [8, 9, 0], [5, 2, 1] ],

[ [0, 1, 1], [5, 5, 9], [3, 8, 4] ] ], 'one')

output = [ [1, 3, 9], [0, 8, 5], [0, 5, 3] ]

In: Computer Science

Explain the shortest seek time first, first come first serve, scan, and c scan algorithms of...

Explain the shortest seek time first, first come first serve, scan, and c scan algorithms of storage management algorithms with the single of the sequence (93, 176, 42, 148, 14, 180).

Draw good diagrams and CALCULATE the total distance traveled and the total waiting time.

initial position is at 50

In: Computer Science

lets say i have a set of data and I want to build an ensemble classifier...

lets say i have a set of data and I want to build an ensemble classifier and wanted to do models for a python machine learning project, how would the startup/build up to put all of that together.

In: Computer Science

1. Give, using “big oh” notation, the worst case running times of the following procedures as...

1. Give, using “big oh” notation, the worst case running times of the following procedures as a function of n ≥ 0.

(a). procedure unknown

for i =1 to n – 1 do

for j =i + 1 to n do

for k =1 to j do

{statements requiring O(1) time}

endfor

endfor

endfor

(b). procedure quiteodd

for i =1 to n do

if odd(i) then

for j =i to n do

x ← x + 1

                           endfor

                           for j =1 to i do

                                        y ← y + 1

                           endfor

             endif

endfor

(c). function recursion (n)

if n <= 1 then

return (1)

else

return (recursion (n – 1) + recursion (n – 1))

endif

2.

The function max (i, n) given below returns the largest element in positions i through i + n – 1 of an integer array A. Assume for convenience that n is a power of 2.

function max(i, n)

if n = 1 then

             return (A[i])

else

             m1 ← max (i, n/2)

             m2 ← max (i + n/2, n/2)

if m1 < m2 then

return (m2)

else

             return (m1)

endif

             endif

(a). Let T(n) denote the worst-case time taken by max with the second argument n. Note that n is the number of elements of which the largest is to be determined. Write an equation expressing T(n) in terms of T(j) for j < n and constants that represent the times taken by statements of the program.

(b). Obtain a big theta bound on T(n).  

In: Computer Science

What is the legal business structure of the company (sole proprietorship, partnership, corporation, LLC/LLP, etc.)? Why...

What is the legal business structure of the company (sole proprietorship, partnership, corporation, LLC/LLP, etc.)? Why was this legal business structure chosen?

In: Computer Science

(16) Convert the following numbers into 8-bit hexadecimal values. Number Binary Complemented Two's Complement Hex -102...

(16) Convert the following numbers into 8-bit hexadecimal values.
Number Binary Complemented Two's Complement Hex
-102
-87
-31
(17) Add up the first two binary numbers from the previous problem in Two’s complement form.  
(17a) What is the sum in hex?
(17b) What is the sign bit?
(17c) Did overflow occur?
(17d) Code this up in 68K and include a screenshot of the output here as well as your source & listing files. What happens?

Please show work!

If you can't do 17 d I understand, no worries!!!

In: Computer Science

I need to write a C++ program that will generate random numbers between the ranges of...

I need to write a C++ program that will generate random numbers between the ranges of your own choice and within the random numbers, indicate the maximum, minimum and the average of the random numbers.

In: Computer Science

Given a csv file named “result_niwtawq.csv”, extract the data from it. Store the first column data...

Given a csv file named “result_niwtawq.csv”, extract the data from it. Store the first column data to a list named time, second column data to a list named Turb_annual_avg, third column data to a list named Turb_min, fourth column data to a list named Turb_max, fifth column data to a list named Turb_mean. Calculate and write the average, maximumand minimumof Turb_min to a file named “lab3_output.txt”.

https://dropbox.cse.sc.edu/pluginfile.php/256369/mod_assign/introattachment/0/result_niwtawq.csv?forcedownload=1

In: Computer Science

The First National Bank of Parkville recently opened up a new “So You Want to Be...

The First National Bank of Parkville recently opened up a new “So You Want to Be a Millionaire” savings account. The new account works as follows:

  • The bank doubles the customer’s balance every year until the customer’s balance reaches one million.
  • The customer isn’t allowed to touch the money (no deposits or withdrawals) until the customer’s balance reaches one million. If the customer dies before becoming a millionaire, the bank keeps the customer’s balance.
  • Note:Customers close to $1,000,000 tend to get “accidentally” run over in the bank’s parking lot.

Write a java program that prompts the user for a starting balance and then prints the number of years it takes to reach $100,000 and also the number of years it takes to reach $1,000,000.

Sample session:

Enter starting balance: 10000
It takes 4 years to reach $100,000.
It takes 7 years to reach $1,000,000.

In: Computer Science

3. Write a Java program to demonstrate the concept of priority thread. It should show that...

3. Write a Java program to demonstrate the concept of priority thread. It should show that each thread have a priority. Priorities are represented by a number between 1 and 20. In most cases, thread schedular schedules the threads according to their priority (known as preemptive scheduling). But it is not guaranteed because it depends on JVM specification that which scheduling it chooses.


3 constants defined in Thread class:
1. public static int MIN_PRIORITY
2. public static int NORM_PRIORITY
3. public static int MAX_PRIORITY

Default priority of a thread is 5 (NORM_PRIORITY). The value of MIN_PRIORITY is 1 and
the value of MAX_PRIORITY is 20.

Here is an example of priority of a Thread:
1. class TestMultiPriority1 extends Thread{
2. public void run(){
3.    System.out.println(&quot;running thread name is:&quot;+Thread.currentThread().getName());
4.    System.out.println(&quot;running thread priority is:&quot;+Thread.currentThread().getPriority());
5.   }

6. public static void main(String args[]){
7.   TestMultiPriority1 m1=new TestMultiPriority1();
8.   TestMultiPriority1 m2=new TestMultiPriority1();
9.   m1.setPriority(Thread.MIN_PRIORITY);
10.   m2.setPriority(Thread.MAX_PRIORITY);
11.   m1.start();
12.   m2.start();
13.  
14. }
15. }

In: Computer Science

Python 3.7.4 ## Tombstones ''' A Grave is a dictionary with two keys: * 'Name': A...

Python 3.7.4

## Tombstones

'''
A Grave is a dictionary with two keys:
* 'Name': A string value with the grave's occupant's name
* 'Message': A string value with the grave's message
'''

Grave = {'name': str, 'Message': str}


'''
G1. Define the function `count_grave_all` that consumes a list of graves
and produces an integer representing the number of characters needed to
write all of the message of the grave. Include spaces and new lines.
'''


'''
G2. Define the function `count_grave_characters` that consumes a list of graves
and produces an integer representing the number of characters needed to
write all of the message of the grave. Do not count spaces and new lines.
'''


'''
G3. Define a function named `estimate_grave_cost` that consumes a list of graves
and produces an integer representing the total estimate lettering cost by
multiplying the number of letters on the grave (ignoring spaces and newlines) by
the cost of writing a letter ($2).
'''


"""
G4. Define a function named `count_shouters` that consumes a list of graves
and produces an integer representing the number of graves that had their
messages in all capital letters. Hint: use the `.upper()` method.
"""

In: Computer Science

Function Return Value In this program, you will be using C++ programming constructs, such as functions...

Function Return Value

In this program, you will be using C++ programming constructs, such as functions and loops.

main.cpp

Write a program that allows the user to enter the information for multiple packages to determine the shipping charges for each package. The program will exit when the user enters 0 or negative for the package weight.

Your program will ask the user to enter the weight of a package they want to ship. If the weight they enter is a positive number, your program will then prompt the user to enter the distance the package will be shipped. Your program will then output the shipping charges with a precision of 2 digits past the decimal point, and will prompt the user for the next package.

calculateCharge

Create a function called calculateCharge that contains 2 parameters: a double to represent the weight of the package, and an integer to represent the distance the package will be shipped. This function returns the shipping charge. See types.hpp for the function prototype for this function.

This function calculates the charge based on the package weight as well as the distance. The rates per weight are defined in types.hpp. And that rate is multiplied by how many 500 mile segments the package will be traveling. For instance, if the distance is 1-500 then the rate is multiplied by one. If the distance is 501-1000 then the rate is multiplied by two. 1001-1500, multiplied by three, and so forth.

Input Validation

  1. You can assume the user will always input valid data types (floating-point for package weight and integer for distance).

Hints

  1. Be sure to include the file types.hpp with the #include files so that the compiler knows where to find the program constants and function prototype.
  2. Shipping charges should be displayed with a precision of 2 digits past the decimal point.
  3. Don't forget to add comments to explain what the code is doing and where control of the program is executing.
  4. Choose variable names and function names that describe the purpose of the variable.

Sample Output

Welcome to Fast Freight Shipping Company

Enter the package weight in lbs (or 0 to exit): 0
Welcome to Fast Freight Shipping Company

Enter the package weight in lbs (or 0 to exit): 33
Enter shipping distance in miles: 3

Shipping cost: $6.40

Enter the package weight in lbs (or 0 to exit): -1
Welcome to Fast Freight Shipping Company

Enter the package weight in lbs (or 0 to exit): 3.4
Enter shipping distance in miles: 501

Shipping cost: $8.40

Enter the package weight in lbs (or 0 to exit): 3.4
Enter shipping distance in miles: 500

Shipping cost: $4.20

Enter the package weight in lbs (or 0 to exit): 1.1
Enter shipping distance in miles: 1100

Shipping cost: $9.30

Enter the package weight in lbs (or 0 to exit): 1.1
Enter shipping distance in miles: 1

Shipping cost: $3.10

Enter the package weight in lbs (or 0 to exit): 0

Here is is the information on the types.hpp file to be used:


//-----------
// Constants
//-----------

// shipping distance per segment

const int SEGMENT_MILES = 500;

// rates per 500 miles shipped

const double RATE1 = 3.10; // pkgs weighing <= 2 lb
const double RATE2 = 4.20; // pkgs > 2 lb but <= 6 lb
const double RATE3 = 5.30; // pkgs > 6 lb but <= 10 lb
const double RATE4 = 6.40; // pkgs > 10 lb


//---------------------
// Function prototypes
//---------------------

// This function receives a package weight in lbs and
// a shipping distance in miles. It uses these to compute
// and return the shipping charge.

double calculateCharge(double weight, int distance);

In: Computer Science

ALGORITHMS AND ANALYSIS Show with a counterexample that the greedy approach does not always yield an...

ALGORITHMS AND ANALYSIS

Show with a counterexample that the greedy approach does not always yield an optimal solution for the Change problem when the coins are U.S. coins and we do not have at least one of each type of coin.

In: Computer Science

Write a program to compute numeric grades for a course. The course records are in a...

Write a program to compute numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format:


Each line contains a student’s last name, then one space, followed by the student’s first name, then one space, then ten or fewer quiz scores.


(If there are fewer than ten scores, that means the student missed one or more quizzes.) The quiz scores are whole numbers and are separated by one space. Your program will take its input from this file and send its output to a second file. The data in the output file will be the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student’s quiz scores. The average score is the sum of the quiz scores divided by 10. This amounts to giving the student a 0 for any missed quiz.


The output file will contain a line (or lines) at the beginning of the file explaining the output. Use formatting instructions to make the layout neat and easy to read.


After placing the desired output in an output file, your program will close all files and then copy the contents of the output file to the input file so that the net effect is to change the contents of the input file.


Use at least two functions that have file streams as all of some of their arguments.

Hint: Check out putback member function. See topic in Files menu.

SAMPLE OUTPUT


Input file:

test_ line_ 10 20 30 40 50 60 70

Price Betty 40 50 60 70 60 50 30 60 90

Goodman John 60 70 80 90 100 90

Smith Charles 70 80 90 60 70 60 80 90 90 90

Spangenberg Ward 70 70 80 90 70 80 90 80 70 60

Output file:

Last Name, First Name, up to 10 quiz scores. last entry is the average.

test_ line_ 10 20 30 40 50 60 70 28.00

Price Betty 40 50 60 70 60 50 30 60 90 51.00

Goodman John 60 70 80 90 100 90 49.00

Smith Charles 70 80 90 60 70 60 80 90 90 90 78.00

Spangenberg Ward 70 70 80 90 70 80 90 80 70 60 76.00


Point Distribution:
-50 Does not compile
-5 Warnings
-5 No description multiple line comments (name, date, etc)
-5 No single line comments (logic, input, output, etc)
-20 Does not use at least 2 programmer defined functions with stream passing.
-10 Does not copy output file to input file
-10 Does not format output


can you please send the answer to my emil [email protected]

thank you

C++

C++

In: Computer Science

Programming in C Game of Craps PR01 The game of craps is often said to be...

Programming in C Game of Craps

PR01
The game of craps is often said to be the “fairest” casino game of pure chance (meaning that
there is no player strategy involved) in that the house has the smallest advantage over the
player. What is that advantage? To answer this question we need to first define, precisely, what
we mean by “advantage”. The house advantage is simply the fraction of bets placed that will go
to the house, on average.


To estimate the house advantage for craps perform a Monte Carlo simulation of the game for
many millions of games, keeping track of the total amount bet and the total amount collected
by the house.


The rules of craps are very simple (note that we are not considering “side bets”). A player
places a wager and they will either lose the game (and their wager) or they will win the game
(and get both their wager and an equal payout from the house). Each game consists of a
number of throws of two fair six-sided dice (with sides equal to {1,2,3,4,5,6}. On each roll the
sum of the two dice is calculated. On the first roll, if a player rolls a 7 or an 11 they win
immediately. If the first roll is 2, 3, or 12 they lose immediately. Any other result establishes the
player’s “point” for that game. They then continue rolling the dice until they either roll their
point again (and win) or roll a 7 (and lose).


Write a predicate function that plays a single game of craps and returns TRUE if the player wins
and FALSE if the player loses. On each game place a random bet ranging from $1 to $1000
(whole dollar increments is fine). Collect data not only on the total amount wagered and the
total (net) amount taken by the house, but also aggregate data on how long games last and
their outcome. The end result should be output similar to the following (fake data). Note that
the percentages in parens on each line are the percentage of games that lasted that length, not
the fraction of total games played. The last column is the percentage of all games that lasted
that number of rolls.



GAMES PLAYED:........ 1000000
LONGEST GAME:........ 31 rolls
HOUSE ADVANTAGE:..... 1.734%
ROLLS WON LOST % OF GAMES
1 222222 (66.667%) 111111 (33.333%) 33.333
2 22222 ( 2.222%) 11111 ( 1.111%) 17.234
3 2222 ( 0.222%) 11111 ( 1.111%) 8.645
4 222 ( 0.022%) 1111 ( 0.111%) 0.935
...
20 22 ( 0.002%) 1 ( 0.000%) 0.006
>20 2222 ( 0.222%) 111 ( 0.011%) 0.521


PR02
Take a slightly different look at the game of craps by tabulating the odds of winning (the
fraction of the time that the player wins) for each possible mark value. This table should look
something like:
GAMES PLAYED:........ 1000000
FIRST ROLL WIN:...... 22.222%
FIRST ROLL LOSS:..... 11.111%
POINT WON LOST
4 222222 (22.222%) 111111 (11.111%)
5 22222 (22.222%) 111111 (11.111%)
6 2222 (22.222%) 111111 (11.111%)
8 26 (13.222%) 173 (86.778%)
9 222222 (22.222%) 111111 (11.111%)
10 222222 (22.222%) 111111 (11.111%)


Again, note that the numbers above are just effectively random placeholder values.
The percentages for the first-roll figures should be as a fraction of all games played. The
percentages for the values in the table should be as a fraction of all games that used that row’s
point value. The idea is for the player to know that IF their point is 8, then they have a 13%
change of winning that game – so the percentages on each row should sum to 100%.

In: Computer Science