Questions
Suppose you have a list containing exactly three integer numbers. Each number could be positive, negative,...

Suppose you have a list containing exactly three integer numbers. Each number could be positive, negative, or zero. Write a C program that first asks the user for each of the numbers. After that, it should determine and display the number from the list that is nearest to the positive number five (5).

Examples:
If the numbers are 0, -3, and 8, then the displayed output is 8.
If the numbers are 6, 5, and 4, then the output is 5.
If the numbers are 3, 4, and 11, then the output is 4.
If the numbers are 4, 1, 6, then it turns out that 4 and 6 are both equidistant from 5. In this situation, the output should be the first number checked that satisfied the criterion. For this example, if you started on the left at 4 and proceeded to the right, the output is 4.

In: Computer Science

Is the middleware in an Android System considered an example of a middleware in a distributed...

Is the middleware in an Android System considered an example of a middleware in a distributed system?

In: Computer Science

This is a machine learning question. Please use python and google colab format. PLEASE USE BASIC...

This is a machine learning question. Please use python and google colab format. PLEASE USE BASIC MACHINE LEARNING CODES.

Using the Kaggle diamonds dataset, construct a KNN estimator to predict diamond prices. Choose an appropriate K value and predict the price of a diamond with the following parameters: "carat' : 0.32, 'cut' : Ideal, 'color' : E, 'clarity' : IF, 'depth' : 60.7, 'table' : 58.0, 'x' : 4.46, 'y' : 4.48,  'z': 2.71".

Please change the cut, color and clarity to numbers (Eg: cut: 'Fair' : 1, 'Good' : 2, 'Very Good' : 3, 'Premium' : 4, 'Ideal' : 5) etc. I need to predict the price of the specific diamond stated above. Thank you!

In: Computer Science

Implement the Fibonacci function by means of accumulative parameters so that it runs in linear time....

Implement the Fibonacci function by means of accumulative parameters so that it runs in linear time.

(Please use OCaml, Haskell or another functional language and delineate which you are using. Python won't work, unfortunately.)

In: Computer Science

Calculate the total time to transmit a 1000 KB file over a link in the following...

  1. Calculate the total time to transmit a 1000 KB file over a link in the following cases, assuming the one-way delay in either direction is 50ms, and an initial 2 x RTT of "handshaking" before any data is sent.
    1. The bandwidth is 1.5 Mbps, the packet size including the header is 1 KB of which the header is 40 bytes, and data packets are sent continuously and never lost.
    2. Same as (1), but the packet size is 5 KB (incl. header). ·What happens when 15 packets are lost and have to be retransmitted (no time is wasted in detecting which packets have been lost, the last packet in the stream is not retransmitted).
    3. Same as (1), but after we finish transmitting we must wait for one RTT before transmitting the next packet.
    4. Same as (1), but the link bandwidth is "infinite" ( the transmission time is assumed to be zero). We start by sending one packet in the first (2(1 – 1)), during the second RTT we send two ( 2(2-1) )packets, during the third RTT we send four (2(3-1)), and so on.

In: Computer Science

What to submit: your answers to exercises 1, 2, and 3 and separate the codes to...

What to submit: your answers to exercises 1, 2, and 3 and separate the codes to each question..

1. Create a UML diagram to help design the class described in exercise 3 below.

Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public?

2. Write Java code for a Baby class. A Baby has a name of type String and an age of type integer.

Supply two constructors: one will be the default constructor, that just sets default values for the name and age; the second constructor will take two parameters, a string to set the name and an integer to set the age. Also, supply methods for setting the name, setting the age, getting the name and getting the age.

Give Java code for an equals method for the Baby class. Babies count as being the same (i.e. equal) if their names and their ages are exactly identical (names should not be case sensitive). The method will take a Baby type parameter and use the calling object (thus comparing these two objects via name and age); it should return Boolean - true or false as appropriate. Remember, if comparing Strings, you must use String comparison methods.

.   Test your Baby class by writing a client program which uses an array to store information about 4 babies. That is, each of the four elements of the array must store a Baby object.

If you have an array for baby names and another array for baby ages, then you have missed the point of the exercise and therefore not met the requirement of this exercise.

A Baby class object stores the required information about a Baby. So each Baby object will have its own relevant information, and thus each object must be stored in one element of the array.

The client program should:

a. Enter details for each baby (name and age) and thus populate the

Baby array

b. Output the details of each baby from the array (name and age) c. Calculate and display the average age of all babies in the array d. Determine whether any two babies in the array are the same

As the required information for these tasks is stored in the Baby array, you will need to use a loop to access each array element (and use the dot notation to access the appropriate set and get methods to assign/retrieve the information).

For part d above, a nested loop is required.

In: Computer Science

Base class: Polygon Derived classes: Rectangle, Triangle Make Square a derived class of Rectangle. There can...

Base class: Polygon

Derived classes: Rectangle, Triangle

Make Square a derived class of Rectangle.

There can be several ways to represent the shapes. For example, a shape can be represented by an array of side lengths counted in the clock-wise order. For example, {2, 4, 2, 4} for a rectangle of width 2 and height 4, and {4, 4, 4, 4} for a square. You need to design your representation.

Each polygon should have a function area() that returns its area, and perimeter() that returns its perimeter.

The area of a triangle, given three sides a, b, and c, can be calculated using Heron's formula (http://www.mathopenref.com/heronsformula.html).

In a main program, create an array of pointers to Polygon; create at least one object from each derived class, assign it to the array, and print out the area and perimeter of each array member.

Polygon * shapes[3];

shapes[0] = new Rectangle(4.0, 2.0);

shapes[1] = new Square(4.0);

shapes[3] = new Triangle(4.0, 4.0, 4.0);

for (int i=0; i<3)

cout<<shapes[i]->area()<<" ,"<<shapes[i]->perimeter()<<endl;

Design your classes properly by using dynamic binding and well-thought-out constructors.

Submit 9 C++ files in one zip file: one header file and one cpp file for each of the four classes, plus a client.cpp.

In: Computer Science

Please explain with examples means details: 1. What is Data Security Compliance? 2. What is FISMA?...

Please explain with examples means details:

1. What is Data Security Compliance?

2. What is FISMA?

3. Why is data security important in our society?

In: Computer Science

Many Projects are running in the company. The CEO of company wants to know about the...

Many Projects are running in the company. The CEO of company wants to know about the details of his current projects. Write a SQL query that retrieves each project record.

In: Computer Science

this there any way to shorten the line of  code. Right now it about 300 line of...

this there any way to shorten the line of  code. Right now it about 300 line of code is there anyway to shorten it to 200 or so line of code?

import java.awt.*;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.*;
import java.net.URL;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
//MyMenuFrame will use Jframe with actionlistener
class MyMenuFrame extends JFrame implements ActionListener{

//creating the main menu items
JMenu menuEdit = new JMenu("Edit");
JMenu menuPrint = new JMenu("Print");
JMenu mnFile = new JMenu("File");
JMenu menuHelp = new JMenu("Help");


//creating the submenu items here because we are gonna use these across the code
JRadioButton subMenuItem1 = new JRadioButton("Times New Roman");
JRadioButton subMenuItem2 = new JRadioButton("Arial");
JRadioButton subMenuItem3 = new JRadioButton("Serif");
JCheckBox subMenuItem4 = new JCheckBox("Bold");
JCheckBox subMenuItem5 = new JCheckBox("Italic");

//provide scrollable view of a component
JScrollPane scrollPane;

//creating notePadArea for notepad to input the text
JTextArea notePadArea;

public MyMenuFrame() {

//setting the border layout for JFrame
this.setLayout(new BorderLayout());

// create menu bar named menuBar

JMenuBar menuBar = new JMenuBar();

this.setJMenuBar(menuBar);//adding the menubar to JFrame

// create File menu
mnFile.setMnemonic(KeyEvent.VK_F);//Alt+F

menuBar.add(mnFile);//adding the menufile

// create Open menu item

JMenuItem mntmOpen = new JMenuItem("Open");//creating the Open menu

mntmOpen.setMnemonic(KeyEvent.VK_O);//Alt+O command

mntmOpen.setActionCommand("open");//when the command equals to 'open' then the corresponding action will be performed

mntmOpen.setAccelerator(KeyStroke.getKeyStroke('O', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+O

mntmOpen.addActionListener(this);//adding actionLister to the Menu Option Open


// create Save menu item

JMenuItem mntmSave = new JMenuItem("Save");//creating the Save menu

mntmSave.setMnemonic(KeyEvent.VK_S);//Alt+S command

mntmSave.setActionCommand("save");//when the command equals to 'save' then the corresponding action will be performed

mntmSave.setAccelerator(KeyStroke.getKeyStroke('S', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+S

mntmSave.addActionListener(this);//adding actionLister to the Menu Option Save

// create Exit menu item

JMenuItem mntmExit = new JMenuItem("Exit");//creating the Exit menu

mntmExit.setMnemonic(KeyEvent.VK_X);//Alt+X command

mntmExit.setActionCommand("exit");//when the command equals to 'exit' then the corresponding action will be performed

mntmExit.setAccelerator(KeyStroke.getKeyStroke('X', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+X

mntmExit.addActionListener(this);//adding actionLister to the Menu Option Exit

// add open, save and exit menu to menu-bar

mnFile.add(mntmOpen);

mnFile.addSeparator();//adding separator between open and save

mnFile.add(mntmSave);

mnFile.addSeparator();//adding separator between save and exit

mnFile.add(mntmExit);

// create Edit menu

menuEdit.setMnemonic(KeyEvent.VK_E);//creating shortcut menu when user press Alt+E

menuBar.add(menuEdit);//adding the Edit to the menubar

JMenu submenu1 = new JMenu("Color");//creating the new menu which comes under Edit
submenu1.setMnemonic(KeyEvent.VK_C);//creating shortcut menu when user press Alt+C
JMenuItem menuItem0 = new JMenuItem("Change Color");//creating submenu item called change color
menuItem0.setAccelerator(KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK));//it responds when user click Ctrl+C
menuItem0.setActionCommand("color");//setting the command used to call the correcponding action when user click this
menuItem0.addActionListener(this);//adding actionlistener
submenu1.add(menuItem0);//adding this menu item to submenu
menuEdit.add(submenu1);//adding this submenu to editmenu
menuEdit.addSeparator();//creating separator between Color and Font

ActionListener sm1 = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
subMenuItem1.setSelected(true);
subMenuItem2.setSelected(false);
subMenuItem3.setSelected(false);
notePadArea.setFont(new Font("Times New Roman", Font.PLAIN, 20));
}
};

ActionListener sm2 = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
subMenuItem2.setSelected(true);
subMenuItem1.setSelected(false);
subMenuItem3.setSelected(false);
notePadArea.setFont(new Font("Arial", Font.PLAIN, 20));

}
};

ActionListener sm3 = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
subMenuItem3.setSelected(true);
subMenuItem2.setSelected(false);
subMenuItem1.setSelected(false);
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));

}
};

JMenu submenu = new JMenu("Font");//creating the new menu which comes under Edit
submenu.setMnemonic(KeyEvent.VK_F);//creating shortcut menu when user press Alt+F
subMenuItem1.setMnemonic(KeyEvent.VK_T);//creating shortcut menu when user press Alt+T for Times New Roman
subMenuItem1.setActionCommand("times_new_roman");//setting the command used to call the correcponding action when user click this
subMenuItem1.addActionListener(sm1);//adding actionlistener
submenu.add(subMenuItem1);//adding to the submenu


subMenuItem2.setMnemonic(KeyEvent.VK_A);//creating shortcut key Alt+A
subMenuItem2.setActionCommand("arial");//respond when the command equals to arial
subMenuItem2.addActionListener(sm2);//adding action listener
submenu.add(subMenuItem2);//adding it to the submenu

subMenuItem3.setMnemonic(KeyEvent.VK_S);
subMenuItem3.setActionCommand("serif");
subMenuItem3.addActionListener(sm3);
submenu.add(subMenuItem3);

submenu.addSeparator();

subMenuItem4.setMnemonic(KeyEvent.VK_B);
subMenuItem4.setActionCommand("bold");
subMenuItem4.addActionListener(this);
submenu.add(subMenuItem4);

subMenuItem5.setMnemonic(KeyEvent.VK_I);
subMenuItem5.setActionCommand("italic");
subMenuItem5.addActionListener(this);
submenu.add(subMenuItem5);

menuEdit.add(submenu);


// create Print menu


menuPrint.setMnemonic(KeyEvent.VK_P);

menuBar.add(menuPrint);

JMenuItem menuItemPrint = new JMenuItem("Send To Printer");

menuItemPrint.setAccelerator(KeyStroke.getKeyStroke('P', KeyEvent.CTRL_DOWN_MASK));

menuItemPrint.setActionCommand("print");

menuItemPrint.addActionListener(this);

menuPrint.add(menuItemPrint);

// create Help menu

menuHelp.setMnemonic(KeyEvent.VK_H);


menuBar.add(menuHelp);

JMenuItem menuItemHelp = new JMenuItem("About");

menuItemHelp.setAccelerator(KeyStroke.getKeyStroke('A', KeyEvent.CTRL_DOWN_MASK));

menuItemHelp.setActionCommand("about");
menuItemHelp.addActionListener(this);

JMenuItem menuItemVisitHomePage = new JMenuItem("Visit Home Page");

menuItemVisitHomePage.setAccelerator(KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK));

menuItemVisitHomePage.setActionCommand("visithomepage");
menuItemVisitHomePage.addActionListener(this);

menuHelp.add(menuItemHelp);

menuHelp.addSeparator();

menuHelp.add(menuItemVisitHomePage);

notePadArea = new JTextArea();

// set no word wrap

notePadArea.setWrapStyleWord(false);

// create scrollable pane

scrollPane = new JScrollPane(notePadArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS , JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

this.add(scrollPane,BorderLayout.CENTER);

}


@Override

public void actionPerformed(ActionEvent e) {

if(e.getActionCommand().equals("exit")) {

System.exit(0);

}else if (e.getActionCommand().equals("open")) {

JFileChooser file = new JFileChooser();

String fileName = "";//initial filename was empty

// show open file dialog

if (file.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {

fileName = file.getSelectedFile().getAbsolutePath();

} else {

return;

}

try(BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));) {

// load file content into text area

StringBuffer stringBuffer = new StringBuffer();//creating a string buffer for reading data from file

String lines = "";//for reading the lines from the selecting file

while((lines = bufferedReader.readLine() ) != null) {//it'll read untill the file ends

stringBuffer.append(lines).append("\n");//for every line read insert new line in stringBuffer

}

bufferedReader.close();//after reading of file done, the bufferedReader will be close

notePadArea.setText(stringBuffer.toString());//converting the read text to string and inserting this text into textArea

} catch (Exception error1) {//if any exception occures

System.out.println(error1.toString());//convert the expection into string and print it

}

} else if (e.getActionCommand().equals("save")) {//if the user click the save command then the file will gonna saved


JFileChooser file = new JFileChooser();//creating the file chooser

String fileName = "";//initial file name is empty

// show open file dialog

if (file.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {//if the user select file and clicks OK button

fileName = file.getSelectedFile().getAbsolutePath();

} else {//other wise will be closed
return;
}

try(BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName));) {

// write editor's content to selected file.

bufferedWriter.write(notePadArea.getText());//get the text entered in textarea
bufferedWriter.flush();//clear the writer
} catch(Exception ex1) {}

} else if (e.getActionCommand().equals("color")) {

Color select_color = JColorChooser.showDialog(this, "Select a color", Color.RED);
notePadArea.setForeground(select_color);

} else if (e.getActionCommand().equals("times_new_roman")) {
if(subMenuItem1.isSelected())
notePadArea.setFont(new Font("Times New Roman", Font.PLAIN, 20));

} else if (e.getActionCommand().equals("arial")) {
if(subMenuItem2.isSelected())
notePadArea.setFont(new Font("Arial", Font.PLAIN, 20));

} else if (e.getActionCommand().equals("serif")) {
if(subMenuItem3.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));

} else if (e.getActionCommand().equals("bold")) {
if(subMenuItem4.isSelected()){
if(subMenuItem5.isSelected()){
notePadArea.setFont(new Font("Serif", Font.BOLD+Font.ITALIC, 20));
}else{
notePadArea.setFont(new Font("Serif", Font.BOLD, 20));
}
}else{
if(!subMenuItem5.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));
}

} else if (e.getActionCommand().equals("italic")) {

if(subMenuItem5.isSelected()){
if(subMenuItem4.isSelected()){
notePadArea.setFont(new Font("Serif", Font.BOLD+Font.ITALIC, 20));
}else{
notePadArea.setFont(new Font("Serif", Font.ITALIC, 20));
}
}else{
if(!subMenuItem4.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));
}

} else if (e.getActionCommand().equals("print")) {

int output = JOptionPane.showConfirmDialog(this, "Do you want to print the File","Confirmation", JOptionPane.YES_NO_OPTION);
if(output==0){
JOptionPane.showMessageDialog(this, "The file is successfully printed","Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else if (e.getActionCommand().equals("changecolor")){
System.out.println("Color clicked");
}
else if (e.getActionCommand().equals("about")) {

JOptionPane.showMessageDialog(this, "This software is developed in 2019\nVersion is 1.0","About", JOptionPane.INFORMATION_MESSAGE);

} else if (e.getActionCommand().equals("visithomepage")) {

openWebpage("http://www.microsoft.com");

}

}

private void openWebpage (String urlString) {

try {

Desktop.getDesktop().browse(new URL(urlString).toURI());

}

catch (Exception e) {

e.printStackTrace();
}
}
}

import javax.swing.JFrame;
public class MyMenuFrameTest {
public static void main(String[] args) {
MyMenuFrame frame = new MyMenuFrame();
frame.setTitle("MyNotepad");
//for the title of the box
frame.setSize(600, 400);
//for the size of the box
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);
}
}

In: Computer Science

TCP Wireshark Lab – Working with a remote server.  You will go through the steps below, use...

TCP Wireshark Lab – Working with a remote server.  You will go through the steps below, use your captured wireshark file and the provided wireshark file (on D2L) to answer the questions.  When you have finished the lab you will submit the following:

  1. This document with your answers provided in the appropriate places.  
  2. Your wireshark capture file as a zipped file.  

STEPS:

1. Start up your web browser. Go thehttp://gaia.cs.umass.edu/wireshark-labs/alice.txtand retrieve an ASCII copy of Alice in Wonderland. Store this file somewhere on your computer.

2. Next go to http://gaia.cs.umass.edu/wireshark-labs/TCP-wireshark-file1.html.

3. Use the Browse button in this form to enter the name of the file (full path name) on your computer containing Alice in Wonderland (or do so manually). Don’t press the “Upload alice.txt file” button, yet!

4. Now start up Wireshark and begin packet capture (Capture->Start) and then press OK on the Wireshark Packet Capture Options screen (we’ll not need to select any options here).

5. Returning to your browser, press the “Upload alice.txt file” button to upload the file to the gaia.cs.umass.edu server. Once the file has been uploaded, a short congratulations message will be displayed in your browser window.

6. Stop Wireshark packet capture and save your capture file. Your Wireshark window should look similar to the window shown below.

———————————————————————————————————————————————————————-

PART 2: A first Look At the Captured Trace  

Use the provided online capture (uploaded in D2L as a zip file – you will need to extract it before opening in Wireshark) to answer the following:

1. What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.edu? To answer this question, it’s probably easiest to select an HTTP message and explore the details of the TCP packet used to carry this HTTP message, using the “details of the selected packet header window”.  (5 pts answer, 5 pts explanation of which packet # you used to answer this question)

2. What is the IP address of gaia.cs.umass.edu? On what port number is it sending and receiving TCP segments for this connection? (5 pts for answer, 5 pts for explanation of which packet # )

Use your own Captureto answer the following:

3. What is the IP address and TCP port number used by your client computer (source) to transfer the file to gaia.cs.umass.edu? (10 pts – with screenshot of your capture)

———————————————————————————————————————————————————————-

PART 3: TCP Basics

4. What is the sequence number of the TCP SYN segment that is used to initiate the TCP connection between the client computer and gaia.cs.umass.edu? What is it in the segment that identifies the segment as a SYN segment? (5 pts for answer, 5 pts for packet #)

5. What is the sequence number of the SYNACK segment sent by gaia.cs.umass.edu to the client computer in reply to the SYN? What is the value of the Acknowledgement field in the SYNACK segment? How did gaia.cs.umass.edu determine that value? What is it in the segment that identifies the segment as a SYNACK segment? (5 pts for answer , 5 pts for screenshot of highlighted packet)

6. What is the sequence number of the TCP segment containing the HTTP POST command? Note that in order to find the POST command, you’ll need to dig into the packet content field at the bottom of the Wireshark window, looking for a segment with a “POST” within its DATA field. (5 pts for answer, 5 pts for screenshot of highlighted packet)

7. Consider the TCP segment containing the HTTP POST as the first segment in the TCP connection. What are the sequence numbers of the first six segments in the TCP connection (including the segment containing the HTTP POST)? At what time was each segment sent? When was the ACK for each segment received? (10 pts)

8. What is the length of each of the first six TCP segments? (10 pts)

9. What is the minimum amount of available buffer space advertised at the received for the entire trace? Does the lack of receiver buffer space ever throttle the sender? (10 pts)

10. Are there any retransmitted segments in the trace file? What did you check for (in the trace) in order to answer this question? (10 pts)

———————————————————————————————————————————————————————-

PART 4: TCP Congestion Control In Action

STEPS:

1. Select a TCP segment in the Wireshark’s “listing of captured-packets” window. Then select the menu : Statistics->TCP Stream Graph-> Time-SequenceGraph(Stevens).  

QUESTIONS:

Answer Question 11 Using the provided Capture (Bonus: 10 pts)

11. Use the Time-Sequence-Graph(Stevens) plotting tool to view the sequence number versus time plot of segments being sent from the client to the gaia.cs.umass.edu server. Can you identify where TCP’s slowstart phase begins and ends, and where congestion avoidance takes over? Insert a screenshot of your Time-Sequence-Graph and explain your answer.

In: Computer Science

In JAVA: Create a circular doubly linked list. It need not be generic. Implement addToStart and...

In JAVA:

Create a circular doubly linked list. It need not be generic. Implement addToStart and addToEnd methods, as well as printList method. Implement delete(Node n) method that deletes a node n, if n is in the linked list. Make no assumptions about n. Test your linked list.

In: Computer Science

1. What is exception handling? 2. Name a few common types of exceptions.

1. What is exception handling?

2. Name a few common types of exceptions.

In: Computer Science

Subject: Computer Algorithms 3) Design an efficient algorithm that sorts an array containing 2 sorted sets...

Subject: Computer Algorithms

3) Design an efficient algorithm that sorts an array containing 2 sorted sets of numbers, such as A=[3,4,7,9,13,1,5,6,8] (Note that [3,4,7,9,13] and [1,5,6,8] are both sorted, but A is not). Your algorithm declaration should look like this:

MYSORT(A,p,n)

where A is the input array, p is the index to the first element of the second set of numbers, and n is the length of array A.

Calculate the asymptotic running time and space of you algorithm.

Reference book

Introduction to Algorithms 3rd edition

Ebook URL:

http://ce.bonabu.ac.ir/uploads/30/CMS/user/file/115/EBook/Introduction.to.Algorithms.3rd.Edition.Sep.2010.pdf

In: Computer Science

IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...

IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade a student earned in each test, and the average of all grades in each test.

Your output should look like this:

Mary's average grade was 78.8%

Harry's average grade was 67.7%

etc... :

In test 1 the highest grade was 93% and the average was 89.2%

In test 2........etc

Your main method should be modular.

Write a method that inputs the 5 names into an array (one dimensional), and returns this array to main

Write a method that inputs the 15 (integer) test grades into a (two-dimensional) array, and returns this array to main.

Write a method that calculates the students averages and stores them in an array , and returns this array to main

Write a method that calculates the average grade for each test and stores them in an array, and returns this array to main

Write a method that determines the highest grade for each test and stores this in an array , and returns this array to main. MAIN will print all the information. The printing could be done easily by the methods instead of having to store the information in an array, but this will give you practice in arrays and methods - all useful for the final exam.

Thanks a lot, please include the comments.

In: Computer Science