Please write unit tests for the main method below. The unit tests must be used in MSTest for Visual Studio.
C#
//main method
public static void Main(string[] args)
{
//unsorted array
int[] dataSet = new int[5] { 2, 99, 27, 68, 3 };
//sortData method
called for sorting the above unsorted array
sortData(dataSet);
//iterating the sorted
array
for (int i = 0; i < dataSet.Length; i++)
{
//writing the sorted array to the console
Console.WriteLine(dataSet[i]);
}
}//end method
In: Computer Science
can someone please complete this for me? losing my mind
Assignment Overview
The Case Assignment in Module 2 will accomplish three tasks:
Case Assignment
Write a java program to help you calculate property tax. The program will perform the following tasks:
Your task:
In: Computer Science
what is the network administration standards ?
briefly
course: Network Administration
In: Computer Science
Please provide new response
Virtualization technology has dramatically changed the landscape of how servers are designed, secured, and administered. The hypervisor market has become commoditized due to core feature overlap among most hypervisor vendors. While there are many hypervisor options in the market today–the Big 3 are VMware (ESXi), Microsoft (Hyper-V), and Citrix (XenServer). On the basis of your understanding of Virtualization technology , create a report in a Microsoft Word document addressing the following: Compare and contrast the Big 3 hypervisor options available in the market on the basis of factors such as:
Features Licensing costs Security Support Make a recommendation to Zeus Books on which hypervisor they should use to create a high availability web server environment.
In: Computer Science
Write a Python program that allows the user to perform three operations (implemented as three functions) on a dictionary:
add_to_dict(): takes a dictionary, a key, a value and adds the
<key,value> pair to the dictionary. If the key is already in
the dictionary, then the program displays the error message:
"Error. Key already exists.".
remove_from_dict(): takes a dictionary and key and removes the key
from the dictionary. If no such key is found in the dictionary then
the program prints: "Key not found."
find_key(): takes dictionary and key and returns the value
associated with the key or None if not found. The program prints
the value if found, else prints: "Key not found."
No printing should be done inside these three functions.
The user is presented with a menu and repeatedly offered to perform an operation until he/she quits.
Finally, a list of the key-value pairs in the dictionary is printed out.
The main program is given - do not change it.
Example 1:
Menu:
(a)dd, (r)emove, (f)ind: a
Key: rich
Value: 1
More (y/n)? y
Menu:
(a)dd, (r)emove, (f)ind: a
Key: alireza
Value: 2
More (y/n)? n
[('alireza', '2'), ('rich', '1')]
def main():
more_input = True
a_dict = {}
while more_input:
choice =
menu_selection()
execute_selection(choice, a_dict)
again = input("More
(y/n)? ")
more_input =
again.lower() == 'y'
tuple_list = dict_to_tuples(a_dict)
print(sorted(tuple_list))
main()
In: Computer Science
Question(on Python). There is a Python program what could solve the simple slide puzzles problem by A* algorithm. Please fill in the body of the a_star() function.
In order to solve a specific problem, the a_star function needs to know the problem's start state, the desired goal state, and a function that expands a given node. To be precise, this function receives as its input the current state and the goal state and returns a list of pairs of the form (new_state, h'-score). There is exactly one such pair for each of the possible moves in the current state, with new_state being the state resulting from that move, paired with its h'-score. Note that this is not the f'-score but the h'-score, i.e., an (optimistic) estimate of the number of moves needed to reach the goal from the current state. The expand function does not know g’and therefore cannot compute f'; this has to be done by the a_star function.
The a_star function calls the expand function (in this context,
slide_expand) in order to expand a node in the search tree, i.e.,
obtain the states that can be reached from the current one and
their h’-scores. Again, please note that these are not f’-scores
but h’-scores;
a_star needs to compute the h’-scores for sorting the list of open
nodes. Also, note that slide_expand does not (and cannot) check
whether it is creating a search cycle, i.e., whether it generates a
state that is identical to one of its ancestors; this has to be
done by a_star. The given slide_expand function uses the same
scoring function as discussed in class – it simply counts the
number of mismatched tiles (excluding the empty tile).
Please add code to the a_star function so that slide_solver can find an optimal solution for Example #1 and, in principle, for any slide puzzle. You are not allowed to modify any code outside of the a_star function. Hints: It is best to not use recursion in a_star but rather a loop that expands the next node, prevents any cycles in the search tree, sorts the list of open nodes by their scores, etc., until it finds a solution or determines that there is no solution. It is also a good idea to keep a list of ancestors for every node on the list, i.e., the list of states from the start that the algorithm went through in order to reach this node. When a goal state is reached, this list of ancestors for this node can be returned as the solution.
A_Star.py
import numpy as np
example_1_start = np.array([[2, 8, 3],
[1, 6, 4],
[7, 0, 5]])
example_1_goal = np.array([[1, 2, 3],
[8, 0, 4],
[7, 6, 5]])
example_2_start = np.array([[ 2, 6, 4, 8],
[ 5, 11, 3, 12],
[ 7, 0, 1, 15],
[10, 9, 13, 14]])
example_2_goal = np.array([[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
[13, 14, 15, 0]])
# For a given current state, move, and goal, compute the new state and its h'-score and return them as a pair.
def make_node(state, row_from, col_from, row_to, col_to, goal):
# Create the new state that results from playing the current move.
(height, width) = state.shape
new_state = np.copy(state)
new_state[row_to, col_to] = new_state[row_from, col_from]
new_state[row_from, col_from] = 0
# Count the mismatched numbers and use this value as the h'-score (estimated number of moves needed to reach the goal).
mismatch_count = 0
for i in range(height):
for j in range(width):
if new_state[i ,j] > 0 and new_state[i, j] != goal[i, j]:
mismatch_count += 1
return (new_state, mismatch_count)
# For given current state and goal state, create all states that can be reached from the current state
# (i.e., expand the current node in the search tree) and return a list that contains a pair (state, h'-score)
# for each of these states.
def slide_expand(state, goal):
node_list = []
(height, width) = state.shape
(empty_row, empty_col) = np.argwhere(state == 0)[0] # Find the position of the empty tile
# Based on the positin of the empty tile, find all possible moves and add a pair (new_state, h'-score)
# for each of them.
if empty_row > 0:
node_list.append(make_node(state, empty_row - 1, empty_col, empty_row, empty_col, goal))
if empty_row < height - 1:
node_list.append(make_node(state, empty_row + 1, empty_col, empty_row, empty_col, goal))
if empty_col > 0:
node_list.append(make_node(state, empty_row, empty_col - 1, empty_row, empty_col, goal))
if empty_col < width - 1:
node_list.append(make_node(state, empty_row, empty_col + 1, empty_row, empty_col, goal))
return node_list
# TO DO: Return either the solution as a list of states from start to goal or [] if there is no solution.
def a_star(start, goal, expand):
return []
# Find and print a solution for a given slide puzzle, i.e., the states we need to go through
# in order to get from the start state to the goal state.
def slide_solver(start, goal):
solution = a_star(start, goal, slide_expand)
if not solution:
print('This puzzle has no solution. Please stop trying to fool me.')
return
(height, width) = start.shape
if height * width >= 10: # If numbers can have two digits, more space is needed for printing
digits = 2
else:
digits = 1
horizLine = ('+' + '-' * (digits + 2)) * width + '+'
for step in range(len(solution)):
state = solution[step]
for row in range(height):
print(horizLine)
for col in range(width):
print('| %*d'%(digits, state[row, col]), end=' ')
print('|')
print(horizLine)
if step < len(solution) - 1:
space = ' ' * (width * (digits + 3) // 2)
print(space + '|')
print(space + 'V')
slide_solver(example_1_start, example_1_goal) # Find solution to example_1
In: Computer Science
Give an O(lg n)-time EREW algorithm that determines for each object in an n-object list whether it is the middle (n/2
th) object.
In: Computer Science
|
IN JAVA Inheritance Using super in the constructor Using super in the method Method overriding |
Write an application with five classes Vehicle, Car, Bus, Truck, and Tester class with main method in it.
The following characteristics should be used: make, weight, height, length, maxSpeed, numberDoors, maxPassenges, isConvertable, numberSeats, maxWeightLoad, and numberAxels.
Characteristics that are applicable to all vehicles should be instance variables in the Vehicle class. The others should be in the class(s) where they belong.
Class vehicle should have constructor that initializes all its data. Classes Car, Bus, and Truck will have constructors which will reuse their parents constructor and provide additional code for initializing their specific data.
Class Vehicle should have toString method that returns string representtion of all vehicle data. Classes Car, Bus, and Truck will override inherited toString method from class vehicle in order to provide appropriate string representation of all data for their classes which includes inherited data from Vehicle class and their own data.
Class Tester will instantiate 1-2 objects from those four classes (at least five total) and it will display the information about those objects by invoking their toString methods.
Submit one word document with code for all five classes, picture of program run from blueJ, and picture of UML diagram.
In: Computer Science
please i want solution for this question with algorithm and step by step with c++ language
In: Computer Science
list and discuss ten shortcomings of artificial neural networks
In: Computer Science
Introduction to Algorithms - Analysis of Algorithms
Solve the following recurrence relation: T(n) = T(an) + T((1 - a)n) + n
In: Computer Science
In: Computer Science
Complete the reading of NIST Special Publication 800-145 (2011).
NIST Definition of Cloud Computing, then branch out into Internet
research on how the term “Cloud Computing” has evolved and what it
means now. You can talk about how cloud services are increasingly
relevant to businesses today. Feel free to use an example for
Infrastructure as a Service (IaaS) or Software as a Service (Saas)
and talk about why companies are moving their onsite infrastructure
to the cloud in many cases. Think Microsoft Azure, Amazon Web
Services, Rackspace, or any number of cloud providers.
Go ahead and have a little fun with it if you like also: Pretend
you are an IT manager and need to recommend a solution for moving a
piece of software or hardware into the cloud. What provider would
you use and why? Or would you instead recommend keeping
servers/software in house?
You must post your initial response (with APA 6th ed or higher
references) before being able to review other students' responses.
Once you have made your first response, you will be able to reply
to other students’ posts. You are expected to make a minimum of 3
responses to your fellow students' posts.
In: Computer Science
What would have to be changed in the code if the while statement were changed to:
while (menu == 5);
Code is as follows
#include <stdio.h>
void printHelp ()
{
printf ("\n");
printf ("a: a(x) = x*x\n");
printf ("b: b(x) = x*x*x\n");
printf ("c: c(x) = x^2 + 2*x + 7\n");
printf ("d: shrink(x) = x/2\n");
printf ("q: quit\n");
}
void a(float x)
{
float v = x*x;
printf (" a(%.2f) = %.2f^2 = %.2f\n", x, x, v);
} // end function a
void b(float x)
{
float v = x*x*x;
printf (" b(%.2f) = %.2f^3 = %.2f\n", x, x, v);
} // end function b
void c(float x)
{
float v = x*x + 2*x + 7;
printf (" c(%.2f) = %.2f^2 + 2*%.2f + 7 = %.2f\n",
x, x, x, v);
} // end function c
void shrink(float x){
float v = x/2;
printf("shrink(%.2f) = %.2f/2 = %.2f\n", x, x, v);
}//end of function shrink
int menu ()
{
char selection;
float x;
printHelp ();
scanf ("%s", &selection);
if (selection == 'q')
return 1;
scanf ("%f", &x);
if (selection == 'a')
a(x);
if (selection == 'b')
b(x);
if (selection == 'c')
c(x);
if(selection == 'd')
shrink(x);
return 0;
} // end function menu
int main()
{
while (menu() == 0);
printf ("... bye ...\n");
return 0;
} // end main
In: Computer Science