Why use parallelism? In a 500-word paper, define the
ways of measuring speed of computers, and discuss how parallelism
is used in super- computing. Include in your answer:
The ways we can measure speed.
Examples of super-computing and how it is being
used.
In: Computer Science
This code is an expression of cp command in c language. But I don't understand this code very well. Please explain in notes one by one.
#define SIZE 1024
#include<string.h>
#include<stdio.h>
#include<sys/types.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/stat.h>
int main(int argc, char *argv[]){
if(argc != 3){
perror("argument 부족\n");
exit(0);
}
struct stat frstatbuf;
FILE* fr = fopen(argv[1], "r");
if(fr == NULL){
perror("read file 읽기 오류\n");
exit(0);
}
int frfd = fileno(fr);
fstat(frfd, &frstatbuf);
FILE* fw=fopen(argv[2], "w+");
int fwfd=fileno(fw);
fchmod(fwfd,frstatbuf.st_mode&(S_IRWXU|S_IRWXG|S_IRWXO));
char buf[1024];
while(1){
int n=fread(buf,sizeof(char),SIZE,fr);
if(n<SIZE){
fwrite(buf,sizeof(char),n,fw);
printf("파일을 다 읽었음\n");
exit(0);
}
fwrite(buf,sizeof(char),n,fw);
}
fclose(fr);
fclose(fw);
return 0;
}
In: Computer Science
Create the logic for a program that stores 5 names in an array.
Your program will then ask the user which name (s)he wants to search. The program receives the name to be searched as input and searches the array for the name entered.
If the name is one of the names in the array, display the message "Name found.". Otherwise, display the message "Name not found.".
in pseudocode please in python
In: Computer Science
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int -*mySet: myType -MAX_VALUE = 500000 static const: int -LIMIT = 1000 static const: int +recursionSet() +recursionSet(const recursionSet&) +~recursionSet() +getSetLength() const: int +generateElements(int): void + getElement(int) const: myType +setElement(int, myType): void +readValue(const string) const: int +printSet() const: void +operator == (const recusrionSet&): bool +tak(myType, myType, myType) const: myType +printSeptenary(myType) const: void +squareRoot(myType, myType) const: myType -recSqRoot(myType, myType, myType) const: myType +recursiveSum() const: myType -rSum(int) const: myType +checkParentheses(string) const: bool -recChkPar(string, int, int) const: bool +recursiveInsertionSort(): void -recInsSort(int, int): void -insertInOrder(myType, int, int): voidYou may add additional private functions if needed (but, not for the recursive functions). Note, points will be deducted for especially poor style or inefficient coding. Function Descriptions • The recursionSet() constructor should set the length to 0 and mySet pointer to NULL. • The recusrsionSet(const recursionBucket&) copy constructor should create a new, deep copy from the passed object. • The ~recursionSet() destructor should delete the myType array, set the pointer to NULL, and set the size to 0. • The setElement(int, myValue) function should set an element in the class array at the given index location (over-writing any previous value). The function must include bounds checking. If an illegal index is provided, a error message should be displayed. • The getElement(int) should get and return an element from the passed index. This must include bounds checking. If an illegal index is provided, a error message should be displayed and a 0 returned. • The getSetLength() functions should return the current class array length. • The printSet(int) function should print the formatted class array with the passed number of values per line. Use the following output statement: cout << setw(5) << mySet[i] << " • "; Refer to the sample executions for formatting example. The readValue(string) function should prompt with the passed string and read a number from the user. The function should ensure that the value is 3 1 and £ MAX_VALUE. The function should handle invalid input (via a try/catch block). If an error occurs (out of range or invalid input) an appropriate message should be displayed and the user re- prompted. Example error messages include: cout << "readSetLenth: Sorry, too many " << "errors." << endl; cout << "readSetLenth: Error, value " << cnt << " not between 1 and " << numMax << "." << endl; • Note, three errors is acceptable, but a fourth error should end the function and return 0. The generateList(int) function should dynamically create the array and use the following casting for rand() to fill the array with random values. mySet[i] = static_cast(rand()%LIMIT); • • • The printSeptenary(myType) function should print the passed numeric argument in Septenary (base-7) format. Note, function must be written recursively. The recursiveSum() function will perform a recursive summation of the values in class data set and return the final sum. The function will call the private rSum(int) function (which is recursive). The rSum(int) function accepts the length of the data set and performs a recursive summation. The recursive summation is performed as follows: rSum ( position )= • { array[ 0] array[ position ] + rSum ( position−1) if position = 0 if position > 0 The tak(myType) function should recursively compute the Tak 1 function. The Tak function is defined as follows: tak ( x , y , z) = { z tak ( tak ( x−1, y , z) , tak ( y−1, z , x) , tak ( z −1, x , y ) ) 1 For more information, refer to: http://en.wikipedia.org/wiki/Tak_(function) if y≥ x if y < x• • The squareRoot(myType, myType) function will perform a recursive estimation of the square root of the passed value (first parameter) to the passed tolerance (second parameter). The function will call the private sqRoot(myType,myType,myType) function (which is recursive). The private recSqRoot(myType,myType,myType) function recursively determines an estimated square root. Assuming initially that a = x, the square root estimate can be determined as follows: recSqRoot ( x , a , epsilon) = • • • • • { 2 if ∣ a − x ∣ ≤ epsilon a 2 (a + x) sqRoot x , , epsilon 2 a ( ) if ∣ a 2 − x ∣ > epsilon The recursiveInsertionSort() function should sort the data set array using a recursive insertion sort. The recursiveInsertionSort() function should verify the length is valid and, if so, call the recInsSort() function to perform the recursive sorting (with the first element at 0 and the last element at length-1). The recInsSort(int, int) function should implement the recursive insertion sort. The arguments are the index of the first element and the index of the last element. If the first index is less than that last index, the recursive insertion sort algorithm is follows: ▪ Recursively sort all but the last element (i.e., last-1) ▪ Insert the last element in sorted order from first through last positions To support the insertion of the last element, the insertInOrder() function should be used. The insertInOrder(myType, int, int) function should recursively insert the passed element into the correction position. The arguments are the element, the starting index and the ending index (in that order). The function has 3 operations: ▪ If the element is greater than or equal to the last element in the sorted list (i.e., from first to last). If so, insert the element at the end of the sorted (i.e, mySet[last+1] = element). ▪ If the first is less than the last, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and continue the insertion by recursively calling the insertInOrder() function with the element, first, and last-1 values. ▪ Otherwise, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and set the last value (i.e., mySet[last]) to the passed element. The checkParentheses(string) function should determine if the parentheses in a passed string are correctly balanced. The function should call the private recChkPar(string, int, int) function (which is recursive) The recChkPar(string, int, int) function should determine if the parentheses in a string are correctly balanced. The arguments are the string, an index (initially 0), and a parenthesis level count (initially 0). The index is used to track the current character in the string. The general approach should be as follows: ◦ Identify base case or cases. ◦ Check the current character (i.e., index) for the following use cases: ▪ if str[index] == '(' → what to do then ▪ if str[index] == ')' → what to do then ▪ if str[index] == any other character → what to do then Note, for each case, increment the index and call function recursively.
In: Computer Science
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int -*mySet: myType -MAX_VALUE = 500000 static const: int -LIMIT = 1000 static const: int +recursionSet() +recursionSet(const recursionSet&) +~recursionSet() +getSetLength() const: int +generateElements(int): void + getElement(int) const: myType +setElement(int, myType): void +readValue(const string) const: int +printSet() const: void +operator == (const recusrionSet&): bool +tak(myType, myType, myType) const: myType +printSeptenary(myType) const: void +squareRoot(myType, myType) const: myType -recSqRoot(myType, myType, myType) const: myType +recursiveSum() const: myType -rSum(int) const: myType +checkParentheses(string) const: bool -recChkPar(string, int, int) const: bool +recursiveInsertionSort(): void -recInsSort(int, int): void -insertInOrder(myType, int, int): voidYou may add additional private functions if needed (but, not for the recursive functions). Note, points will be deducted for especially poor style or inefficient coding. Function Descriptions • The recursionSet() constructor should set the length to 0 and mySet pointer to NULL. • The recusrsionSet(const recursionBucket&) copy constructor should create a new, deep copy from the passed object. • The ~recursionSet() destructor should delete the myType array, set the pointer to NULL, and set the size to 0. • The setElement(int, myValue) function should set an element in the class array at the given index location (over-writing any previous value). The function must include bounds checking. If an illegal index is provided, a error message should be displayed. • The getElement(int) should get and return an element from the passed index. This must include bounds checking. If an illegal index is provided, a error message should be displayed and a 0 returned. • The getSetLength() functions should return the current class array length. • The printSet(int) function should print the formatted class array with the passed number of values per line. Use the following output statement: cout << setw(5) << mySet[i] << " • "; Refer to the sample executions for formatting example. The readValue(string) function should prompt with the passed string and read a number from the user. The function should ensure that the value is 3 1 and £ MAX_VALUE. The function should handle invalid input (via a try/catch block). If an error occurs (out of range or invalid input) an appropriate message should be displayed and the user re- prompted. Example error messages include: cout << "readSetLenth: Sorry, too many " << "errors." << endl; cout << "readSetLenth: Error, value " << cnt << " not between 1 and " << numMax << "." << endl; • Note, three errors is acceptable, but a fourth error should end the function and return 0. The generateList(int) function should dynamically create the array and use the following casting for rand() to fill the array with random values. mySet[i] = static_cast(rand()%LIMIT); • • • The printSeptenary(myType) function should print the passed numeric argument in Septenary (base-7) format. Note, function must be written recursively. The recursiveSum() function will perform a recursive summation of the values in class data set and return the final sum. The function will call the private rSum(int) function (which is recursive). The rSum(int) function accepts the length of the data set and performs a recursive summation. The recursive summation is performed as follows: rSum ( position )= • { array[ 0] array[ position ] + rSum ( position−1) if position = 0 if position > 0 The tak(myType) function should recursively compute the Tak 1 function. The Tak function is defined as follows: tak ( x , y , z) = { z tak ( tak ( x−1, y , z) , tak ( y−1, z , x) , tak ( z −1, x , y ) ) 1 For more information, refer to: http://en.wikipedia.org/wiki/Tak_(function) if y≥ x if y < x• • The squareRoot(myType, myType) function will perform a recursive estimation of the square root of the passed value (first parameter) to the passed tolerance (second parameter). The function will call the private sqRoot(myType,myType,myType) function (which is recursive). The private recSqRoot(myType,myType,myType) function recursively determines an estimated square root. Assuming initially that a = x, the square root estimate can be determined as follows: recSqRoot ( x , a , epsilon) = • • • • • { 2 if ∣ a − x ∣ ≤ epsilon a 2 (a + x) sqRoot x , , epsilon 2 a ( ) if ∣ a 2 − x ∣ > epsilon The recursiveInsertionSort() function should sort the data set array using a recursive insertion sort. The recursiveInsertionSort() function should verify the length is valid and, if so, call the recInsSort() function to perform the recursive sorting (with the first element at 0 and the last element at length-1). The recInsSort(int, int) function should implement the recursive insertion sort. The arguments are the index of the first element and the index of the last element. If the first index is less than that last index, the recursive insertion sort algorithm is follows: ▪ Recursively sort all but the last element (i.e., last-1) ▪ Insert the last element in sorted order from first through last positions To support the insertion of the last element, the insertInOrder() function should be used. The insertInOrder(myType, int, int) function should recursively insert the passed element into the correction position. The arguments are the element, the starting index and the ending index (in that order). The function has 3 operations: ▪ If the element is greater than or equal to the last element in the sorted list (i.e., from first to last). If so, insert the element at the end of the sorted (i.e, mySet[last+1] = element). ▪ If the first is less than the last, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and continue the insertion by recursively calling the insertInOrder() function with the element, first, and last-1 values. ▪ Otherwise, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and set the last value (i.e., mySet[last]) to the passed element. The checkParentheses(string) function should determine if the parentheses in a passed string are correctly balanced. The function should call the private recChkPar(string, int, int) function (which is recursive) The recChkPar(string, int, int) function should determine if the parentheses in a string are correctly balanced. The arguments are the string, an index (initially 0), and a parenthesis level count (initially 0). The index is used to track the current character in the string. The general approach should be as follows: ◦ Identify base case or cases. ◦ Check the current character (i.e., index) for the following use cases: ▪ if str[index] == '(' → what to do then ▪ if str[index] == ')' → what to do then ▪ if str[index] == any other character → what to do then Note, for each case, increment the index and call function recursively.
In: Computer Science
Consider a super market which has different categories of items like grocery, stationary, cosmetics, etc. Under each category, the shop holds a maximum capacity of 100 items. The arrangement of items in the racks vary from time to time. Based on the item type and availability, the supplier also varies. Each supplier can supply different items. The system in the supermarket has the complete description of list of all items which includes item number, name, category, supplier name, price, total quantity and qty available. Based on the items purchased by the customer, billing is done.
From the above description, initially the owner of the shop needs to allocate the rack for the available items randomly and a data structure in the system to hold the descriptions of items. When the owner checks for an item in the stock, it should show all information related to that item(qty available is calculated based on count of type of item purchased by the customer). When the purchased items are entered in the billing section ,it should print item no, item name, qty taken, price and total price of all the items and finally the grand total to be paid .Help the owner of the shop to achieve the above said using an interactive C program which uses appropriate data structures for allocation of space for items, defining the type of items, calculating the total and providing the bill for the customers. The program should be in such a way to handle both the owner and the customer part.[Hint: Use menu driven method and appropriate derived data types like pointers,structures to achieve the result]
In: Computer Science
The TOPCAR taxi company is developing a new computer system to be used to support taxi booking and corporate client credit accounts. This computer system aims to automate some manual processes and cut down on labour costs as TOPCAR has many customers from large corporate companies, e.g. CEO, and managers often need taxi trips to the airport. The following describes the activities that must be processed by the computer system:
A client company must first register and open a credit account with TOPCAR at TOPCAR’s website, in which case certain credit checks are made such as checking credit history of client company’s debt level. If the client company has no bad debt history, a credit account for the client company is set up.
At least 24 hours after successful account registration, authorized persons from such client company can request a taxi booking form TOPCAR’s website. When this happens, the availability of a taxi at the requested date and time is checked, as is the credit status of the client company checked. (Note that credit status in finance means a measure of a lender’s willingness to lend money to a particular person or organization, depending on their ability to repay).
If these two checks are successful, a booking is made, and a written confirmation is sent via SMS and emailed to client company. After the customer from the client company has used the taxi, the driver sends in a record of the work, including the cost, and this is added to client company’s account. (Note that driver is an outsourced worker from TOPCAR’s point of view.) At the end of each month, taxi bills are sent via SMS and emailed to client companies for settlement.
From the above description, draw a data flow diagram showing the flow of input information (and/or data) and output information (and/or data) to and from processes and database stores within this computer system and any external environmental elements that interact with this computer system. In this diagram, you must identify the following:
in (a) (5.5 marks)
(Hint: there are two environmental elements that interact with this computer system, and six main processes in this computer system)
In: Computer Science
Represent the decimal number -6 in binary using 4-bits:
3a) signed magnitude ____________________________
3b) 1’s complement _____________________________
3c) 2’s complement _____________________________
In: Computer Science
JAVA PROJECT USING NETBEANS
An application that keeps a record of family profiles in a city that are qualified in the program. Only one member of the family is allowed to apply for the SAP ( is a program/Organization) and that is the head of the family. Qualified families are those that belong to the poorest of the poor whose total daily earning is 550 or below per day. (Assume that the income is the only qualification. In reality there are more like senior citizens, indigent people, disabled persons, etc.)
Minimum Requirement:
The application/ program must be able to do the ff:
• process an application for the program which is the SAP. Make sure that the applicant is qualified and that there was no prior application made by any member of his family.
(OPTIONAL if you can only do this part) • generate a sorted list of all SAP (is a program/organization) beneficiaries in the city.
(OPTIONAL if you can only do this part) • generate a sorted list of SAP (is a program/organization) beneficiaries per family size.
(OPTIONAL if you can only do this part) • count the number of beneficiaries that earn less than 100 per day.
In: Computer Science
Develop a program that magnifies (monochrome) image by a factor of 2^N using bilinear interpolation. Implement this up-scaling in 2 different ways: 1) directly, i.e. calling interp2 once; and 2) ? times iteratively doubling the size. Compare the outputs and discuss the variation in the output (if any).
In: Computer Science
Translate the following segment of Python into ARMv8 assembly. You may assume that two positive integers a and b have already been stored in registers X0 and X1. , which should have the correct end values for a and b at the end of the code.
while a != b: if a>b: a = a - b else: b = b - a
Note: Labels must be on their own line, and all programs must start with the label main:
Test
X0=49 X1=64
Expected
X0: 1
In: Computer Science
C++ and leave comments explaining. Thank you
You are given two STL lists X and P where n P is already in sorted order. Write a valid C++ function
printPositions(X,P) that prints the elements in X specified by P. For example, if P = 0, 3, 7, 8, the elements in positions 0 (head of the list), 3, 7, and 8 in
X are printed. You may use only the public STL container operations. Also specify the running time of your algorithm using Big-Oh notation.
Hint: You may wish to use iterators while keeping track of the position of items being iterated through.
In: Computer Science
Write a program that given a number entered through a cell, say if it is positive or not positive.
programming language is VB8
In: Computer Science
MATLAB: Write a function called max_number that takes an at most two-dimensional matrix A as its sole input. The function returns the largest element of A. You are not allowed to use the built-in max function.
In: Computer Science
in BASIC language, i need to make function smallMiles(size) display the smallest number in the MilesDriven array . here is my code so far:
size =1
Dim Monthname$(size)
Dim MilesDriven(size)
do
print "Enter your choice from this menu."
print "Enter 'P' to enter miles and month,OR"
print "Enter 'S' to search for month. OR,"
print "Enter 'M to search month with smallest miles. OR,"
print "Enter 'L' to search for month with largest miles. OR,"
print "Enter 'E' to exit."
input choice$
select case (choice$)
case "P","p"
res= collectData(size)
case "S","s"
res = search(size)
case "M","m"
res = smallMiles(size)
case "L","l"
res = largeMiles(size)
case "E","e"
print "Have a nice day.Goodbye."
case else
print "Invalid choice, please try again"
print
end select
loop until (choice$ = "E" or choice$ = "e" )
function collectData(size)
for position= 0 to size
print "Enter miles."
input MilesDriven(position)
print "Enter month."
input Monthname$(position)
next
end function
function search(size)
print "Enter month."
input month$
for position = 0 to size
if(month$ = Monthname$(position))then
print "The month is: ";Monthname$(position)
print "The number of miles driven is: ";MilesDriven(position)
exit for
end if
next
end function
function smallMiles(size)
print "Enter month."
input month$
for position = 0 to size
smallest = MilesDriven(position)
if (month$ = Monthname$(position))then
if (MilesDriven(position) < smallest )then
smallest = MilesDriven(position)
end if
print "The month with smallest miles driven is:
";Monthname$(position)
print "The smallest miles driven is: ";smallest
exit for
end if
next
end function
In: Computer Science