Questions
Use the median of 3 partitioning algorithm (given in the next page) to implement quick sort....

Use the median of 3 partitioning algorithm (given in the next page) to implement quick sort. This algorithm chooses the pivot element as the median of the 3 elements namely: A[p], A[r], and A[(p+r)/2].(Java language)

Quicksort(A,p,r)

1 if p

2 N = r- p +1

3 m = Median3(A, p, p + N/2 , r)

4 exchange A[m] with A[r]

5 q = Partition (A,p,r)

6 Quicksort(A,p, q-1)

7 Quicksort(A,q+1,r)

In: Computer Science

Write a function of interest to you. It should that take at least 3 inputs from...

Write a function of interest to you. It should that take at least 3 inputs from different types and return at least three different values.

Call your function from the main.

Print the resultant outputs in the main (not in the function).

In: Computer Science

Construct a DFA machine to recognize the language of all binary numbers which are a multiple...

Construct a DFA machine to recognize the language of all binary numbers which are a multiple of 5.
L = { w belongs {0,1}* : w is a binary number and is a multiple of 5}
Example: 101 belongs to L; 1010 belongs to L; 110 doesn't belong to L.

In: Computer Science

Upsetfowl inC++ knock­off version of the Angry Birds game. The starter program is a working first...

Upsetfowl inC++

knock­off version of the Angry Birds game. The starter program is a working first draft of the game.

1. Correct the first FIXME by moving the intro text to a function named PrintIntro. Development suggestion: Verify the program has the same behavior before continuing.

2. Correct the second FIXME. Notice that the function GetUsrInpt will need to return two values: fowlAngle and fowlVel.

3. Correct the third FIXME. Notice that the function LaunchFowl only needs to return the value fowlLandingX, but needs the parameters fowlAngle and fowlVel.

4. Correct the fourth FIXME. Notice that the function DtrmnIfHit only needs to return the value didHitSwine, but needs the parameters fowlLandingX and swineX. The main should now look like the following code and the program should behave the same as the first draft: intmain(){ doublefowlAngle=0.0;

//angleoflaunchoffowl(rad) doublefowlVel=0.0;//velocityoffowl(m/s) doubleswineX=0.0;//distancetoswine(m) doublefowlLandingX=0.0;

//fowl’shoriz.dist.fromstart(m) booldidHitSwine=false;

//didhittheswine? srand(time(0)); swineX=(rand()%201)+50; PrintIntro(); GetUsrInpt(swineX,fowlAngle,fowlVel); fowlLandingX=LaunchFowl(fowlAngle,fowlVel); didHitSwine=DtrmnIfHit(fowlLandingX,swineX); return0; }

5. Modify the program to continue playing the game until the swine is hit. Add a loop in main that contains the functions GetUsrInpt, LaunchFowl, and DtrmnIfHit.

6. Modify the program to give the user at most 4 tries to hit the swine. If the swine is hit, then stop the loop. Here is an example program execution (user input is highlighted here for clarity):

WelcometoUpsetFowl! TheobjectiveistohittheMeanSwine. TheMeanSwineis84metersaway. Enterlaunchangle(deg):45 Enterlaunchvelocity(m/s):30 Time 1 x= 0 y= 0 Time 2 x= 21 y= 16 Time 3 x= 42 y= 23 Time 4 x= 64 y= 20 Time 5 x= 85 y= 6 Time 6 x=106 y=-16 Missed'em...

TheMeanSwineis84metersaway. Enterlaunchangle(deg):45 Enterlaunchvelocity(m/s):25 Time 1 x= 0 y= 0 Time 2 x= 18 y= 13 Time 3 x= 35 y= 16 Time 4 x= 53 y= 9 Time 5 x= 71 y= -8 Hit'em!!!

In: Computer Science

In MIPS assembly: Ask the user to enter two numbers and an operation (+ - /...

In MIPS assembly:

Ask the user to enter two numbers and an operation (+ - / *).

Print the expression back to the user with a blank after the = sign (since the calculation is not being completed.  

In: Computer Science

C++ Language Write a program that reads the numbers.txt file and stores it into an array...

C++ Language

Write a program that reads the numbers.txt file and stores it into an array of integers. Use the sample functions in the text and in the notes from chapter 8 to sort the array in ascending order (low to high). You can use either method (bubble or selection sort) to accomplish this. Then store the sorted array into an output file sorted Numbers.txt. There are 100 values both positive and negative integers in this file.

In: Computer Science

how to create file: vim hello<your name>.py print “Hello <your name>!” on ubuntu

how to create file: vim hello<your name>.py
print “Hello <your name>!” on ubuntu

In: Computer Science

Compare between connectionless and connection-oriented services by explaining how they work. You should explain their advantages...

Compare between connectionless and connection-oriented services by explaining how they work. You should explain their advantages and disadvantages.

In: Computer Science

A host with IP address 202.11.35.91 is in a subnet that can contain at most 14...

A host with IP address 202.11.35.91 is in a subnet that can contain at most 14 hosts.

a. What is its subnet mask, in dotted-quad notation? [4]

b. What is the subnet's address? [4]

c. What is the last possible IP address in that subnet? [4]

10. For the following IP address and conditions, calculate the information listed below for the Network which contains this address: 173.70.34.3                Subnet Mask: 255.255.240.0

a.           Default Subnet Mask: [2]

b.           Subnet Address:            [3]

c.           First Usable Host Address:       [3]

d.           Last Usable Host Address:       [3]

e.           Broadcast Address:                    [3]

f.            Number of Usable Subnets:    [3]

g.           Number of Usable Hosts/Subnet: [3]

11.        Given the following IP address and conditions, calculate the information listed below for the 3rd

available subnet:          134.6.9.7           You need at least 30 subnets

a.           Subnet Mask: [3]

b.           Subnet Address (for 3rd subnet):        [4]

c.           First Usable Host Address:   [3]

d.           Last Usable Host Address:   [3]

e.           Broadcast Address:      [3]

f.            Number of Usable Subnets:    [3]

g.           Number of Usable Hosts/Subnet:   [3]

In: Computer Science

Translate this algorithm to code on C compare(char array[ ]) word = split(array, " "); //gets...

Translate this algorithm to code on C

compare(char array[ ])

word = split(array, " "); //gets the first word before the blank space

if word == Hello {

print("I am saying hello");

}else if (word == Bye)

print("I am saying goodbye");

}

Example---------------------

char array = "Hello Ana";

compare(array);

char array1 = "Bye Ana"

compare(array1);

result

"I am saying hello"

"I am saying goodbye"

In: Computer Science

Java homework question: Explain how class (static) variables and methods differ from their instance counterparts. Give...

Java homework question:

Explain how class (static) variables and methods differ from their instance counterparts. Give an example of a class that contains at least one class variable and at least one class method. Explain why using a class variable and method rather than an instance variable and method would be the correct choice in the example you select.

In: Computer Science

def DMStoDD(degree, minutes, seconds): dd = abs(degree) + abs(minutes)/60 + abs(seconds)/3600 if degree > 0: return...

def DMStoDD(degree, minutes, seconds):
         
        dd = abs(degree) + abs(minutes)/60 + abs(seconds)/3600

        if degree > 0:
                return dd
        else:
                return -dd

print(DMStoDD(-30, 30, 00))
In this script, add a main program that collects DD or DMS input from the user, then converts it to the other form and reports the converted value.
Directions: The main program needs to gather a string from the keyboard using input() and detect whether it is DD or DMS (Hint: use the split function). Then it must pass the proper DD or DMS values to the functions above to convert.

The DMS input is separated by comma and contains no space. The degree field could be negative to represent a negative value. (E.g. 43,4,23 or -43,4,23)

In: Computer Science

Discuss by no more than a paragraph the following terms: ATM VLANS Wireless Lans NATS Point-To-Point...

Discuss by no more than a paragraph the following terms:

ATM

VLANS

Wireless Lans

NATS

Point-To-Point WANS

In: Computer Science

The Cisco’s layered switching includes three switching layers. What is the purpose of each layer? What...

The Cisco’s layered switching includes three switching layers. What is the purpose of each layer? What switches are typically used in each layer?

In: Computer Science

Create a new project called Lab05b. Keep the main file named main. Write a function readAndPrint,...

  • Create a new project called Lab05b. Keep the main file named main.
  • Write a function readAndPrint, and power with parameters noted below in the Functions.h file.

//Your Last Name

#ifndef FUNCTIONS_H

#define FUNCTIONS_H

#include <fstream>

#include <iostream>

#include <string>

using namespace std;

/*reads from a file

and prints every item to the screen*/

// file contains sets of

//int

//string

//Don't forget to use infile.ignore() between << and getline

//ifstream must be passed by reference

void readAndPrint(ifstream &infile);

//uses a for loop to return the base to the exponent

//e.g. 2^4 = 16

// this fuction should read data.txt file

long power(long base, long exponent);

#endif

  • You should place the function prototypes in a file called Functions.h The function prototype has a semi-colon at the end.
  • Then you should implement in a file called Functions.cpp
  • Finally, declare the infile, and call the readAndPrint function. Then look at the power of 2^3 and 10 ^ 4

  • Create a file named data.txt that has the following information.

1

Alpha

2

Beta

3

Gamma

  • Your functions.cpp AND your lastnamefirstLab05b.cpp should #include “Functions.h”.
  • Remember that you should not #include.cpp files!
  • Implementation detail 4: compile and run with:

In: Computer Science