This is a multiple answer question, meaning any of the 4 statements could be true. From O/S class
A semaphore, in its purest form (like the one we used in the Dining Philosopher's solution), is what
A busy waiting lock. |
||
An atomic integer that has two functions it can use - one that increments it by 1 and one that decrements it by 1. |
||
A Monitor |
||
An atomic integer that can be changed to any value from any other value directly. |
In: Computer Science
In Python:
Key1, value1
Key2, value2
…, …
(Please if you can, provide screenshots)
Thank YOU!
In: Computer Science
A graph G = (V, E) is a near-tree if it is connected and has at most n+ 8 edges, where n = |V |. Give an algorithm with running time O(n) that takes a near-tree G with costs on its edges, and returns a minimum spanning tree of G. Assume all the edge costs are distinct.
In: Computer Science
Given the information below, create the fully labeled Crow's Foot ERD using a specialization hierarchy where appropriate (use Visio). The ERD must contain all primary keys, foreign keys, and main attributes. Business rules are defined as follows:
At a hospital, each patient is classified as either a resident patient or an outpatient. All patients have common attributes - ID, first and last name, and diagnosis - and unique attributes that are specific to their groups. The list of such attributes includes but is not limited to the following: a summary of the treatment received in the hospital (resident patients) and the checkback date (outpatients). In addition, resident patients are classified as patients who need a routine check up, patients who need a surgery, patients who need both a check up and a surgery. Each group is characterized by unique attributes (for instance, a surgery date, etc.). Each patient creates a record in the HOURS table that keeps track of the total number of hours a patient spent in the hospital. The table also includes the “COMMENT” field where any additional information may be recorded. One record is related to one patient only.
Thank you!
In: Computer Science
Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: 1. Display 10 random numbers stored in the array 2. Compute and display the largest number in the array 3. Compute and display the average value of all numbers 4. Exit The options 2 and 3 should call an appropriate user-defined function and pass the array to the function to compute the largest and the average value respectively. Design and call these two user-defined functions. The average value should be calculated and displayed with a precision of two decimal places. The program should loop back to the main menu until the user selects the option to exit the program. Use the register storage class for two the most frequently used variables in your program. Submit your program's source code (i.e., .c file) and a file with screen captures
In: Computer Science
Describe the different types of firewalls that are on the market today and how they differ from one another. Please write two paragraphs on the matter and please explain properly.
In: Computer Science
6. Add code to the main method of your main class to do the following:
Run the program to make sure it works. The output should look something like this:
Testing Polygon constructor
Number of sides: 5
7. Create a Java class file for a RegularPolygon class.
8. Implement the RegularPolygon class.
9. Add code to the main method of your main class to do the following:
Run the program to make sure it works. The output should look something like this:
Testing Polygon constructor
Number of sides: 4
Testing RegularPolygon constructor
Number of sides: 5
Side length: 1.0
Perimeter: 5.0
Testing side length mutator
Number of sides: 5
Side length: 2.0
Perimeter: 10.0
10. Create a Java class file for a RegularTriangle class.
11. Implement the RegularTriangle class.
RegularPolygon.
12. Add code to the main method of your main class to do the following:
Run the program to make sure it works. The output should look something like this:
Testing Polygon constructor
Number of sides: 4
Testing RegularPolygon constructor
Number of sides: 5
Side length: 1.0
Perimeter: 5.0
Testing side length mutator
Number of sides: 5
Side length: 2.0
Perimeter: 10.0
Testing RegularTriangle constructor
Number of sides: 3
Side length: 4.0
Perimeter: 12.0
Height: 3.4641016151377544
Area: 6.928203230275509
Testing height mutator
Number of sides: 3
Side length: 3.464101615137755
Perimeter: 10.392304845413264
Height: 3.0
Area: 5.196152422706632
Testing side length mutator
Number of sides: 3
Side length: 4.0
Perimeter: 12.0
Height: 3.4641016151377544
Area: 6.928203230275509
In: Computer Science
Write a C++ program that will make changes in the list of strings by modifying its last element.
Your program should have two functions:
1. To change the last element in the list in place. That means, without taking the last element from the list and inserting a new element with the new value.
2. To compare, you need also to write a second function that will change the last element in the list by removing it first, and inserting a new element with the new value.
The main creates the list, creates the string variables, populates few elements in the list (couple is enough) and calls the functions to modify the list. After each call to the functions, the main should print out the value of the last element in the list, so the changes are visible. Again, you print the last element not from within the functions, but from the main.
Note 1: You will need to use references to implement the in-place requirement.
Note 2: However difficult that assignment may look like, all information you need on how to work with the list is given to you in the lecture and both your functions implementation are just very few short statements (hint: If you find yourself writing 5 or more lines of codes for each function, you probably do it wrong).
Please Describe all variables and important sections of code.
Need a screenshot of the out put.
In: Computer Science
In: Computer Science
Can this code be rewritten but keeping the same functions as the original and with detailed comments. I'm going to post the original homework lab just in case.
Attached to this assignment is a Java program that converts a text file to a list of hexadecimal numbers. Each of those hexidecimal numbers represents the bit pattern of a character from the file with the parity bits (even parity) for a hamming code inserted. Each text character takes 8 bits and the hamming code adds 4 bits. This hamming code provides single-bit error correction. Requirements 1. The program must be written in Java. If you have not used Java before, you can learn it enough to do this assignment, by looking at the provided program. 2. You can use Eclipse to write, compile and test your program, but you may also use any other development environment you like. Only the .java file will be submitted. 3. The program will use the provided Hamming class. It will implement the decode function. The decode function is the reverse of the encode function, but it also performs single bit correction when necessary. 4. Display a message to the console when an error is corrected, as in the example below. 5. The main function must be rewritten to read hexidecimal numbers from hamming.txt file and write decoded and corrected text to output.txt. 6. Test the program with different input files. The instructor will test it with a hamming.txt file different from the one provided.
import java.io.*; import java.util.*; public class Hamming { private char letter; private int[] bits = new int[12]; private int code; public Hamming(char let) { letter = let; encode(); } public Hamming(int c) { code = c; decode(); } public int getCode() { return code; } public char getLetter() { return letter; } private void encode() { int value = letter; for (int i = 0; i < 12; i++) { if (i != 0 && i != 1 && i != 3 && i != 7) { bits[i] = value % 2; value /= 2; } } bits[0] = bits[2] ^ bits[4] ^ bits[6] ^ bits[8] ^ bits[10]; // ^ is XOR in Java bits[1] = bits[2] ^ bits[5] ^ bits[6] ^ bits[9] ^ bits[10]; bits[3] = bits[4] ^ bits[5] ^ bits[6] ^ bits[11]; bits[7] = bits[8] ^ bits[9] ^ bits[10] ^ bits[11]; code = 0; for (int i = 11; i >= 0; i--) { code *= 2; code += bits[i]; } } private void decode() { int error = 0; int value = code; for (int i = 0; i < 12; i++) { bits[i] = value % 2; value /= 2; } if (bits[0] != (bits[2] ^ bits[4] ^ bits[6] ^ bits[8] ^ bits[10])) error += 1; if (bits[1] != (bits[2] ^ bits[5] ^ bits[6] ^ bits[9] ^ bits[10])) error += 2; if (bits[3] != (bits[4] ^ bits[5] ^ bits[6] ^ bits[11])) error += 4; if (bits[7] != (bits[8] ^ bits[9] ^ bits[10] ^ bits[11])) error += 8; if (error != 0) bits[error - 1] ^= 1; letter = 0; for (int i = 11; i >= 0; i--) { if (i != 0 && i != 1 && i != 3 && i != 7) { letter *= 2; letter += bits[i]; } } if (error != 0) System.out.println("Error in bit " + (error - 1) + " corrected in character " + letter); } public static void main(String[] args) throws FileNotFoundException { Scanner inFile = new Scanner( new File("hamming.txt")); PrintStream outFile = new PrintStream(new File("output.txt")); String line; int code; System.out.println("File hamming.txt opened"); while (inFile.hasNextInt(16)) { code = inFile.nextInt(16); Hamming ham = new Hamming(code); outFile.print(ham.getLetter()); } inFile.close(); System.out.println("File output.txt closed"); } }
In: Computer Science
C# ( asp.net ) 2019 visual studio
I have a dropdown option. If I choose "date" option, I get to enter list of dates like 02/08/1990, 06/14/1890 in (mm/dd/YYYY) format.
How can I sort these dates in ascending order?. Can you provide me some code. Thank you
In: Computer Science
In: Computer Science
Please answer these questions Data Processing and Analysis using python. Thank you
Explain what does each of the following functions do:
1. numpy.mean()
2. pandas.read_csv()
3. matplotlib.pyplot.plot()
In: Computer Science
// I can't get my cpp file to work with my header file and it always says the error comes from compatibility I am using Visual Studio 2015 below is the error only my file path and program name has been erased. The issue comes up in my cpp file with the size_t empty and full functions.
// Error (active) declaration is incompatible with "bool ListType::empty()" (declared at line 12 of ListType.h)
// ListType header file
#ifndef ListType__h
#define ListType__h
#include
class ListType {
public:
ListType();
bool insert(int value);
void eraseAll();
void erase(int);
bool find(int );
size_t size();
bool empty();
bool full();
const ListType & operator = (const ListType
&other);
friend std :: ostream & operator << (std ::
ostream &out, const ListType &list);
protected:
int list[100];
size_t capacity;
size_t count;
private:
};
#endif /* ListType__h */
//my cpp file
#include "ListType.h"
#include
ListType::ListType() {
capacity = 100;
count = 0;
}
bool ListType::insert(int value)
{
bool result = false;
if (!full()) {
list[count] = value;
++count;
result = true;
}
return result;
}
void ListType::eraseAll() {
count = 0;
}
void ListType::erase(int value) {
size_t i = 0;
while (i < count&&value !=
list[i])++i;
if (i < count) {
list[i] = list[--count];
}
}
bool ListType::find(int value) {
bool result = false;
if (!empty()) {
size_t i = 0;
while (i
result = (i }
return result;
}
size_t ListType::size() {
return count;
}
size_t ListType::empty() {
return count = 0;
}
size_t ListType::full() {
return count == capacity;
}
const ListType& ListType:: operator=(const ListType&
source) {
if (this != &source) {
count = source.count;
for (size_t i = 0; i
list[i] =
source.list[i];
}
}
return *this;
}
std::ostream& operator<<(std::ostream &out, const
ListType &other)
{
out << "[ ";
for (unsigned int i = 0;i
{
out << other.list[i] << " ";
}
out << "]";
return out;
}
In: Computer Science
why do microwave antennas need line-of sight(los) communication. Rainfall affects both microwave communication and radio broiadcasting communication , which one will be more affected by rainfall?
In: Computer Science