Questions
We saw that Quicksort actually won’t be “quick” when it attempts to sort some types of...

We saw that Quicksort actually won’t be “quick” when it attempts to sort some types of inputs (e.g., it will take O(n2) time to sort n numbers that are already sorted). List two different ways to improve Quicksort so that it will run “quickly” (on average, in linear time) regardless of the characteristics of the input pattern.

In: Computer Science

2. Write a c++ program that takes from the user the ​number of courses​ and constructs...

2. Write a c++ program that takes from the user the ​number of courses​ and constructs 3 ​dynamic 1D arrays​ with size courses+1. Each array represents a student. Each cell in the array represents a student’s mark in a course. In the last cell of each 1D array you should calculate the average mark of that student. Then output the average mark of all students in each course. Delete any allocated memory. Example Number of courses : 4 50 60 70 20 100 90 80 70 80 90 100 30 Output: 50 60 70 20​ 50 100 90 80 70 ​85 80 90 100 30 ​75 Avg of course 1 = 76.66 Avg of course 2 = 80 Avg of course 3 = 83.33 Avg of course 4 = 40.

In: Computer Science

Information: Consider a banking system with 3 classes:  BankAccount, CheckingAccount, and SavingsAccount, that you are to design...

Information:

Consider a banking system with 3 classes:  BankAccount, CheckingAccount, and SavingsAccount, that you are to design and write. Have CheckingAccount and SavingsAccount inherit from BankAccount. In BankAccount, you should include an account number, an account balance, a deposit method, a toString method, and an abstract withdraw method. Since deposits work the same way in both child classes, make sure they cannot override it. The constructor should only take an initial deposit and generate a random 5 digit account number. The toString should display the account number and the balance.

In the CheckingAccount class add a minimum balance and a standard overdraft fee of $25. Implement the withdraw method so that overdrafts are allowed, but the overdraft fee is incurred if the balance drops below the minimum balance. Override the toString method to display everything the BankAccount toString displays plus the minimum balance. Use the parent class toString to do most of the work.

In the SavingsAccount class add an annual interest rate (with a default value of 1.5%) and a method to recalculate the balance every month. Since the interest rate is annual, make sure to calculate the interest accordingly. Override the toString method to display everything the BankAccount toString displays plus the interest rate. Like the CheckingAccount toString, you should use the parent class to do most of the work.

Question:   Write the Java implementation of the BankAccount. Note, no driver is required.

In: Computer Science

I am new to socket programming and I wish to know what these lines of code...

I am new to socket programming and I wish to know what these lines of code do. I know they are creating UDP sockets, but it would help if someone explained what the code means. Thank you.

Python Code:

import socket

testingSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
testingSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
testingSocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
testingSocket.bind(('0.0.0.0', 50000))
send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
send_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
receiving_thread = Thread(target=self.receivingFunction)
send_thread = Thread(target=self.sendMessage)
broadcast_online_status_thread = Thread(target=onlineStatus)

In: Computer Science

JavaScript Given the following object, log every property name and value to the console using a...

JavaScript

Given the following object, log every property name and value to the console using a loop.

let myObj = {
    id: 12
    name: 'My Object',
    class: 'obj',
    height: 65,
    likeJavascript: true,
    data: [1, 53, 23]
};
  

In: Computer Science

JavaScript Write a function called "first" that takes in two arguments - the first is an...

JavaScript

Write a function called "first" that takes in two arguments - the first is an argument called arr that is an array of numbers, the second is an optional number argument called num(hint: you'll need a default value - look back at the slides).

If "num" was not passed in (since it's optional), the "first" function will return an array containing the first item of the array.

If a value for "num" was given, the "first" function will return an array containing the first "num" values of the array.

See the example output below.

console.log(first([7, 9, 0, -2])); // [7]
console.log(first([], 3)); // [undefined, undefined, undefined]
console.log(first([7, 9, 0, -2], 3)); // [7, 9, 0]
console.log(first([7, 9, 0, -2], 6)); // [7, 9, 0, -2, undefined, undefined]

In: Computer Science

USING MATLAB Where indicated in the script below, write a function, called myflip, which accepts one...

USING MATLAB
Where indicated in the script below, write a function, called myflip, which accepts one vector v (either a column or a row) and outputs the same vector v of the same dimensions, but with the values in reverse order (use MATLAB function flip()). In other words, v will be overwritten by its flipped version. In your function, you may only use length() and floor(). You only need one loop.

%this code tests the function, myflip, which you will write below

v1 = 100*rand(1);

v1 = myflip(v1)

n = randi([2 100], 1, 1);

v2 = 100*rand(1,2*n);

v2 = myflip(v2)

n = randi([2 100], 1, 1);

v3 = 100*rand(2*n+1,1);

v3 = myflip(v3)

In: Computer Science

I. General Description In this assignment, you will create a Java program to read undergraduate and...

I. General Description In this assignment, you will create a Java program to read undergraduate and graduate students from an input file, sort them, and write them to an output file. This assignment is a follow up of assignment 5. Like assignment 5, your program will read from an input file and write to an output file. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. Unlike assignment 5, the Student objects are sorted before they are written to the output file.

• The program must implement a main class, three student classes (Student, UndergradStudent, GradStudent), and a Comparator class called StudentIDComparator.

• The StudentIDComparator class must implement the java.util.Comparator interface, and override the compare() method. Since the Comparator interface is a generic interface, you must specify Student as the concrete type. The signature of the compare method should be public int compare(Student s1, Student s2). The compare() method returns a negative, 0, or positive value if s1 is less than, equals, or is greater than s2, respectively.

• To sort the ArrayList, you need to create a StudentIDComparator object and use it in the Collections’ sort method: StudentIDComparator idSorter = new StudentIDComparator(); Collections.sort(students, idSorter); //students is an arrayList of Students

Heres student.txt

James Bond,200304,3.2,undergraduate,true
Michelle Chang,200224,3.3,graduate,Cleveland State University
Tayer Smoke,249843,2.4,undergraduate,false
David Jones,265334,2.7,undergraduate,true
Abby Wasch,294830,3.6,graduate,West Virginia
Nancy Drew,244833,2.9,graduate,Case Western
Lady Gaga,230940,3.1,undergraduate,false
Sam Jackson,215443,3.9,graduate,Ohio State University

He said you would need aorund 5 classes

In: Computer Science

4.What is the purpose of padding, Message Authentication Code (MAC), handshake protocol, change cyber suite (CCS)...

4.What is the purpose of padding, Message Authentication Code (MAC), handshake protocol, change cyber suite (CCS) protocol?

5.How does TLS provide: confidentiality, availability, integrity, non-repudiation?

6.Is TCP a user of TLS services or does it provide services to TLS (hard question) – explain your answer in one sentence?

7.Does TLS use sequence numbers?

8.Sequence numbers can be used to launch replay attacks (as in TCP).How does TLS protect against replay attacks?

In: Computer Science

Write a java program calls the following methods: a. printStars(): Takes an int (n) as parameter...

Write a java program calls the following methods:

a. printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop.

ex.

6

******

In: Computer Science

Use NumPy to create a My_Array; a 3 by 3 array where in,m = n +...

  1. Use NumPy to create a My_Array; a 3 by 3 array where in,m = n + m. (e.g., the first row first column would be 0+0=0, second row first column would be 1+0=1, etc). complete the following using NumPy:
    1. Compute the mean, median, range, and variance of this array
    2. Find the inverse or pseudo inverse
    3. Find the determinant
  2. Perform the following operations on My_Array
    1. Create My_1D_Array by reshaping My_Array into a 1-dimensional array
    2. Create a new array that is the transpose of My_1D_Array
    3. Add this new array to My_1D_Array, what is the result? Why is this the result we see?

In: Computer Science

Why does pumping strings in a CFL changes two parts of the string simultaneously?

Why does pumping strings in a CFL changes two parts of the string simultaneously?

In: Computer Science

is an operation of selecting a process that is to be serviced by the CPU. a....

is an operation of selecting a process that is to be serviced by the CPU.

a. Overlaying

b. Replacement

c. Paging

d. Scheduling

In: Computer Science

Python Question: Write a function that checks to see if an array of integers is sorted...

Python Question:

Write a function that checks to see if an array of integers is sorted in an increasing fashion, returning true if it is, false otherwise. Test it with at least4 arrays - 2 sorted and 2 not sorted. Use a CSV formatted input file as described in the previous question to run your program through some tests, where again the filename is passed as an argument.

Heres what I have so far:

import sys

# command line arguement 1. a csv file that contained rows of numbers to be tested.

file_name = sys.argv[1]

file = open(file_name)

# function that will check the csv file and see if the rows of numbers are sorted in an increasing pattern.

def is_sorted(arr):

_result = []

for i in range(len(arr) - 1):

if current_arr[i] > current_arr[i+1]:

return False

return True


# Read the file line by line

for line in file.readlines():

# For each line read,

# We create a new array to:

# Store the number we convert from strings,

current_arr = []

# Split the current line by commas,

for number in line.split(','):

# then convert each string in an array to an integer and

# then add it to the current array of numbers

current_arr += [int(number)]

when I order numbers in my csv file not sorted, I still get True returned instead of False

found_index = is_sorted(current_arr)

print(found_index)

In: Computer Science

2 algorithms for Prefix Averages, one that ran in big-Oh n2 time and a second that...

2 algorithms for Prefix Averages, one that ran in big-Oh n2 time and a
second that ran in big-Oh n time. Code up methods for both algorithms. Show through different
input examples and using the Current Time method call how the polynomial time algorithm runs
slower than the linear time version. Use system.out.println statement to show your results.

please who can help with this question In Java
Thank you

In: Computer Science