Answer:
This question is incomplete, here's the complete question:
1. Willow Brook National Bank operates a drive-up teller window that allows customers to complete bank transactions without getting out of their cars. On weekday mornings, arrivals to the drive-up teller window occur at random, with an arrival rate of 24 customers per hour or 0.4 customers per minute. 3. Use the single-server drive-up bank teller operation referred to in Problems 1 to determine the following operating characteristics for the system: a.) The probability that no customers are in the system. b.) The average number of customers waiting. c.) The average number of customers in the system. d.) The average time a customer spends waiting. e.) The average time a customer spends in the system. f.) The probability that arriving customers will have to wait for service.
Explanation:
Arrival rate \lambda = 24 customers per hour or 0.4 customers per minute
Service rate \mu = 36 customers per hour or 0.6 customers per minute (from problem 1)
a.) The probability that no customers are in the system , P0 = 1 - \lambda / \mu
= 1 - (24/36) = 1/3 = 0.3333
b.) The average number of customers waiting
Lq = \lambda^2 / [\mu(\mu - \lambda)] = 242 / [36 * (36 - 24)] = 1.33
c.) The average number of customers in the system.
L = Lq + \lambda / \mu = 1.33 + (24/36) = 2
d.) The average time a customer spends waiting.
Wq = \lambda / [\mu(\mu - \lambda)] = 24 / [36 * (36 - 24)] = 0.0555 hr = 3.33 min
e.) The average time a customer spends in the system
W = Wq + 1/\mu = 0.0555 + (1/36) = 0.0833 hr = 5 min
f.) The probability that arriving customers will have to wait for service.
= 1 - P0 = 1 - 0.3333 = 0.6667
Write an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the user to enter a numeric test score for the student. Create a ScoreException class, and throw a ScoreException for the class if the user does not enter a valid score (less than or equal to 100). Catch the ScoreException, display the message Score over 100, and then store a 0 for the student’s score. At the end of the application, display all the student IDs and scores. g
Answer:
See explaination for the program code
Explanation:
// ScoreException.java
class ScoreException extends Exception
{
ScoreException(String msg)
{
super(msg);
}
}
// TestScore.java
import java.util.Scanner;
public class TestScore
{
public static void main(String args[]) throws ScoreException
{
Scanner sc = new Scanner(System.in);
int studentId[] = { 1201, 1202, 1203, 1204, 1205 };
int scores[] = new int[5];
int score = 0;
for(int i = 0; i < studentId.length; i++)
{
try
{
System.out.print("Enter a numeric test score for the student"+(i+1)+" of Id "+studentId[i]+" : ");
score = sc.nextInt();
if(score < 0 || score > 100)
{
scores[i] = 0;
throw new ScoreException("Input should be between 1 and 100");
}
else
{
scores[i] = score;
}
}
catch(ScoreException ex)
{
System.out.println("\n"+ex.getMessage()+"\n");
}
}
//displaying student details
System.out.println("\n\nStudent Id \t Score ");
System.out.println("=============================");
for(int i = 0; i < studentId.length; i++)
{
System.out.println(studentId[i]+"\t\t"+scores[i]);
}
}
}
Given a collection of n nuts and a collection of n bolts, arranged in an increasing order of size, give an O(n) time algorithm to check if there is a nut and a bolt that have the same size. The sizes of the nuts and bolts are stored in the sorted arrays NUT S[1..n] and BOLT S[1..n], respectively. Your algorithm can stop as soon as it finds a single match (i.e, you do not need to report all matches).
Answer:
See explaination
Explanation:
Keep two iterators, i (for nuts array) and j (for bolts array).
while(i < n and j < n) {
if nuts[i] == bolts[j] {
We have a case where sizes match, output/return
}
else if nuts[i] < bolts[j] {
this means that size of nut is smaller than that of bolt and we should go to the next bigger nut, i.e., i+=1
}
else {
this means that size of bolt is smaller than that of nut and we should go to the next bigger bolt, i.e., j+=1
}
}
Since we go to each index in both the array only once, the algorithm take O(n) time.
5. Modify the file by allowing the owner to remove data from the file: a. Ask the owner to enter a description to remove b. If the description exists, remove the coffee name and the quantity c. If the description is not found, display the message: That item was not found in the file. 6. Modify the file by allowing the owner to delete data from the file: a. Ask the owner to enter a description to delete b. If the description exists, delete the coffee name and the quantity c. Replace the name and quantity of the coffee removed in step b by asking the user to enter a new coffee name and quantity d. If the description i
Answer:
Check the explanation
Explanation:
Code:
# 3------reading Coffe shop Inventory file
f = open('coffeeInventory.txt','r+')#opening file in reading mode
f1 = f.readlines()
numPounds = 0
for i in range(len(f1)):
print(f1[i].split('\n')[0])
if i!=0:
numPounds+=(int((f1[i].split('\n')[0]).split(';')[1]))
#Total pounds of coffee
print("Total pounds of Coffee:",numPounds)
f.close()#closing file
#4---------
f = open('coffeeInventory.txt','a+')#opening file in appending mode
#appending records
f.write('\nGuatemala Antigua;22')
f.write('\nHouse Blend;25')
f.write('\nDecaf House Blend;16')
f.close()#closing file
#5--------
#removing the record as per owner's description
Description = input("enter Description to remove:")
f = open('coffeeInventory.txt','r')#opening files in reading mode
f1 = f.readlines()
found = -1
for i in range(len(f1)):
line = f1[i].split('\n')[0]
des = line.split(';')[0]
if des==Description:
found = i
#storing the previous data
f2= open('coffeeInventory_pre.txt','w+')
f2.writelines(f1)
f2.close()
#removing the data if found
if found==-1:
print("The item was not found in the file")
else:
f1.remove(f1[found])
data_list = f1
f.close()
#modifying file after removing
modify_file = open('coffeeInventory.txt','w+')
for x in data_list:
modify_file.write(x)
modify_file.close()
f.close()
#6--------------
#deleting the record as per owner's description
Description = input("enter Description to delete:")
f = open('coffeeInventory.txt','r')#opening files in reading mode
f1 = f.readlines()
found = -1
for i in range(len(f1)):
line = f1[i].split('\n')[0]
des = line.split(';')[0]
if des==Description:
found = i
if i==-1:
print("The item was not found in the file")
else:
f1.remove(f1[found])
data_list = f1
f.close()
# deleting in the pre_Coffee_inventory file
#finding record
f2 = open('coffeeInventory_pre.txt','r')
f3 =f2.readlines()
found = -1
for i in range(len(f3)):
line = f3[i].split('\n')[0]
des = line.split(';')[0]
if des==Description:
found = i
if i==-1:
print("The item was not found in the file")
else:
f3.remove(f3[found])#deleting record
data_list1 = f3
f2.close()
#modifying pre file
f2 = open('coffeeInventory_pre.txt','w+')
f2.writelines(data_list1)
f2.close()
#opening file in writing mode
modify_file = open('coffeeInventory.txt','w+')
modify_file.writelines(data_list)
modify_file.close()
Answer:
See explaination
Explanation:
#5
#removing the record as per owner's description
Description = input("enter Description to remove:")
f = open('coffeeInventory.txt','r')#opening files in reading mode
f1 = f.readlines()
found = -1
for i in range(len(f1)):
line = f1[i].split('\n')[0]
des = line.split(';')[0]
if des==Description:
found = i
#storing the previous data
f2= open('coffeeInventory_pre.txt','w+')
f2.writelines(f1)
f2.close()
#removing the data if found
if found==-1:
print("The item was not found in the file")
else:
f1.remove(f1[found])
data_list = f1
f.close()
#modifying file after removing
modify_file = open('coffeeInventory.txt','w+')
for x in data_list:
modify_file.write(x)
modify_file.close()
f.close()
#6
#deleting the record as per owner's description
Description = input("enter Description to delete:")
f = open('coffeeInventory.txt','r')#opening files in reading mode
f1 = f.readlines()
found = -1
for i in range(len(f1)):
line = f1[i].split('\n')[0]
des = line.split(';')[0]
if des==Description:
found = i
if i==-1:
print("The item was not found in the file")
else:
f1.remove(f1[found])
data_list = f1
f.close()
# deleting in the pre_Coffee_inventory file
#finding record
f2 = open('coffeeInventory_pre.txt','r')
f3 =f2.readlines()
found = -1
for i in range(len(f3)):
line = f3[i].split('\n')[0]
des = line.split(';')[0]
if des==Description:
found = i
if i==-1:
print("The item was not found in the file")
else:
f3.remove(f3[found])#deleting record
data_list1 = f3
f2.close()
#modifying pre file
f2 = open('coffeeInventory_pre.txt','w+')
f2.writelines(data_list1)
f2.close()
#opening file in writing mode
modify_file = open('coffeeInventory.txt','w+')
modify_file.writelines(data_list)
modify_file.close()
"Suppose that instead of always selecting the first activity to finish, we instead select the last activity to start that is compatible with all previously selected activities. De- scribe how this approach is a greedy algorithm, and prove that it yields an optimal solution."
The greedy algorithm described selects the last activity to start that is compatible with all previously selected activities, and it can be proved optimal using greedy-choice and optimal substructure properties. This algorithm's real-life application is similar to planning a timely route to an event, optimizing decisions step by step.
Explanation:The greedy algorithm approach to solving problems involves making the locally optimal choice at each stage with the hope of finding a global optimum. In the context of activity selection, the approach described in the question is indeed a greedy strategy, where instead of selecting the activity that finishes earliest, you select the activity that starts last while still being compatible with the previously selected activities. The method assumes that by maximizing the starting time of the current activity, we leave as much room as possible for other activities to take place before it.
To prove that this yields an optimal solution, we can use a greedy-choice property and an optimal substructure property. The greedy-choice property ensures that a locally optimal choice leads toward a globally optimal solution. By choosing the last activity to start, we reserve the maximum possible time for all other activities, thus leading to an optimal selection. The optimal substructure property suggests that if we have an optimal solution for a set of activities, then for any subproblem (such as a subset of these activities), a corresponding optimal solution can also be found. Hence, by demonstrating that each greedy step of choosing the latest-starting activity yields a solution as good as any other compatible activity, we prove that the overall selection is optimal.
An analogy for using a greedy algorithm in everyday life is when you're planning to attend an event with a specific time constraint, like a wedding. If you have to arrive by a certain time and consider traffic congestion, you work backwards from the event and plan your departure to optimize your route. This approach is a simple manifestation of a greedy algorithm, where you make the best immediate decision given the information you have.
A greedy algorithm for the activity selection problem involves selecting the last activity to start that is compatible with previously selected activities. This approach is optimal as it maximizes the number of non-overlapping activities by always making the best local choice.
This question is about using a greedy algorithm to solve the activity selection problem by choosing the last activity to start that is compatible with all previously selected activities. Here is a step-by-step explanation:
Initial Sorting: Sort the activities by their start times in decreasing order.Selection Process: Initialize an empty set to keep track of the selected activities. Go through the list of activities, and for each activity, check if it is compatible with the already selected activities (i.e., it does not overlap in time with them).Greedy Choice: Always select the current activity if it is compatible (non-overlapping) with the previously selected activities. Add this activity to the set of selected activities.This approach works because, like the classic greedy approach, it makes a locally optimal choice at each step with the hope of finding a global optimum. When you select the last activity to start that is compatible with the previously chosen activities, you are ensuring that the remaining time is utilized as best as possible, essentially maximizing the number of non-overlapping activities.
Proof of Optimality:
To demonstrate that this greedy algorithm yields an optimal solution, consider the following:
Inductive Hypothesis: Assume that the set of activities selected so far is optimal.Greedy Choice Property: Adding the next last-starting compatible activity preserves the optimality because selecting any earlier starting activity would reduce the number of non-overlapping activities that can be included.Optimal Substructure: By selecting the last compatible activity, we reduce the problem size and solve the smaller problem optimally until no more activities can be selected.Therefore, this approach ensures an optimal solution by maintaining the greedy choice property and optimal substructure, essential characteristics of a greedy algorithm.
A developer has the following class and trigger code:public class InsuranceRates {public static final Decimal smokerCharge = 0.01;}trigger ContactTrigger on Contact (before insert) {InsuranceRates rates = new InsuranceRates();Decimal baseCost = XXX;}Which code segment should a developer insert at the XXX to set the baseCost variable to the value of the class variable smokerCharge?
A. Rates.smokerCharge
B. Rates.getSmokerCharge()
C. ContactTrigger.InsuranceRates.smokerCharge
D. InsuranceRates.smokerCharge
Answer:
InsuranceRates.smokerCharge
Explanation:
To set the baseCost variable to the value of the class variable smokerCharge, the developer needs to replace
Decimal baseCost = XXX;
with
Decimal baseCost = InsuranceRates.smokerCharge;
This is done using the class reference type.
The smokerCharge should be declared in the InsuranceRates class, at first.
For example Ball b;
And then, a new instance of the object from the class is created, using the new keyword along with the class name: b = new Ball();
In comparing to the example I gave in the previous paragraph, the object reference in the program is:
InsuranceRates rates = new InsuranceRates();
Because the smokerCharge is coming from a different class, it can only be assigned to the variable baseCost via the InsuranceRates class to give:
Decimal baseCost = InsuranceRates.smokerCharge;
The correct code segment to set the baseCost variable to the value of the class variable smokerCharge is D. InsuranceRates.smokerCharge.
Explanation:The correct code segment to set the baseCost variable to the value of the class variable smokerCharge is D. InsuranceRates.smokerCharge.
In the given code, the smokerCharge variable is declared as a static final variable in the InsuranceRates class. This means that it can be accessed directly using the class name followed by the variable name.
Therefore, to set the baseCost variable to the value of smokerCharge, we use InsuranceRates.smokerCharge.
Write a while loop that adds the first 100 numbers (from 1 to 100) together. To do so, use a while loop that continues while the condition of cur_num being less than or equal to stop_num is True. Inside the loop, it should add cur_num to the running total variable, and also add 1 to cur_num. Make sure to check at the end that the value of total reflects the total summation.
Answer:
I am writing JAVA and C++ program. Let me know if you want the program in some other programming language.
Explanation:
JAVA program:
public class SumOfNums{
public static void main(String[] args) { //start of main function
int cur_num = 1; // stores numbers
int stop_num= 100; // stops at this number which is 100
int total = 0; //stores the sum of 100 numbers
/* loop takes numbers one by one from cur_num variable and continues to add them until the stop_num that is 100 is reached*/
while (cur_num <= stop_num) {
total += cur_num; //keeps adding the numbers from 1 to 100
//increments value of cur_num by 1 at each iteration
cur_num = cur_num + 1;}
//displays the sum of first 100 numbers
System.out.println("The sum of first 100 numbers is: " + total); }}
Output:
The sum of first 100 numbers is: 5050
C++ program
#include <iostream> //for input output functions
using namespace std; //to identify objects like cin cout
int main(){ //start of main() function body
int cur_num = 1; // stores numbers
int stop_num= 100; // stops at this number which is 100
int total = 0;//stores the sum of 100 numbers
/* loop takes numbers one by one from cur_num variable and continues to add them until the stop_num that is 100 is reached*/
while (cur_num <= stop_num) {
//keeps adding the numbers from 1 to 100
//increments value of cur_num by 1 at each iteration
total += cur_num;
cur_num = cur_num + 1; }
//displays the sum of first 100 numbers
cout<<"The sum of first 100 numbers is: "<<total; }
The output is given in the attached screen shot.
7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output parameters xValNew and yValNew. The function returns void. The transformation is new = (old + 1) * 2. Ex: If xVal = 3 and yVal = 4, then xValNew is 8 and yValNew is 10. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #include using namespace std; /* Your solution goes here */ int main() { int xValNew; int yValNew; int xValUser; int yValUser; cin >> xValUser; cin >> yValUser; CoordTransform(xValUser, yValUser, xValNew, yValNew); cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl; return 0; } 1 test passed All tests passed Run Feedback? How was this section?
Answer:
Here is the CoordTransform() function:
void CoordTransform(int xVal, int yVal, int &xValNew, int &yValNew){
xValNew = (xVal + 1) * 2;
yValNew = (yVal + 1) * 2; }
The above method has four parameters xVal and yVal that are used as input parameters and xValNew yValNew as output parameters. This function returns void and transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew according to the formula: new = (old + 1) *
Here new variables are xValNew and yValNew and old is represented by xVal and yVal.
Here the variables xValNew and yValNew are passed by reference which means any change made to these variables will be reflected in main(). Whereas variables xVal and yVal are passed by value.
Explanation:
Here is the complete program:
#include <iostream>
using namespace std;
void CoordTransform(int xVal, int yVal, int &xValNew, int &yValNew){
xValNew = (xVal + 1) * 2;
yValNew = (yVal + 1) * 2;}
int main()
{ int xValNew;
int yValNew;
int xValUser;
int yValUser;
cin >> xValUser;
cin >> yValUser;
CoordTransform(xValUser, yValUser, xValNew, yValNew);
cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl;
return 0; }
The output is given in the attached screenshot
Suppose a file system can have three disk allocation strategies, contiguous, linked, and indexed. We have just read the information for a file from its parent directory. For contiguous and linked allocation, this gives the address of the first block, and for indexed allocation this gives the address of the index block. Now we want to read the 10th data block into the memory. How many disk blocks (N) do we have to read for each of the allocation strategies?
Answer:
Since we are using three disk allocation strategies,continuous linked and indexed,therof to process and read allocation strategies we need 99830 disk blocks.
Write syntactically correct Javascript code to sort an array of sub-arrays containing integers using the sort and reduce array functions as described below. You will sort the sub-arrays in ascending order by the maximum value found in each sub-array. Your solution would be executed in the following manner:
The question is incomplete. The complete question is:
Write syntactically correct Javascript code to sort an array of sub-arrays containing integers using the sort and reduce array functions as described below. You will sort the sub-arrays in ascending order by the maxium value found in each sub-array. Your solution would be executed in the following manner:
var x = [ [ 2 , 5 , 1 ], [ 1 , 23 ] , [ 3 ] , [ 22, 16, 8 ] ] ;
x.sort(compare);
will result in variable x containing [ 3 ] , [ 2, 5, 1], [ 22 , 16 , 8], [ 1 , 23 ] ]. The maximum value of each sub-array is shown here in bold. Your solution must be written so that when run with the code above, x will contain the sorted array.
Answer:
function compare(a , b) {
var max1 = Math.max(...a); //get the max in array a
var max2 = Math.max(...b); //get the max in array b
return max1 - max2;
}
var x = [ [ 2 , 5 , 1 ], [ 1 , 23 ] , [ 3 ] , [ 22, 16, 8 ] ] ;
x.sort(compare);
Explanation:
Given an array A positive integers, sort the array in ascending order such that element in given subarray which start and end indexes are input in unsorted array stay unmoved and all other elements are sorted.
An array is a special kind of object. With the square brackets, access to a property arr[0] actually come from the object syntax. This is essentially the same as obj[key], where arr is the object, while numbers are used as keys.
Therefore, sorting sub-array in ascending order by the maxium value found in each sub-array is done:
function compare(a , b) {
var max1 = Math.max(...a); //get the max in array a
var max2 = Math.max(...b); //get the max in array b
return max1 - max2;
}
var x = [ [ 2 , 5 , 1 ], [ 1 , 23 ] , [ 3 ] , [ 22, 16, 8 ] ] ;
x.sort(compare);
Write a program that does the following: • Alphabetizes a list of small (non-capital) letters. For consistency, make the string 12-15 random small letters. Label the sequence "string 1" in the data statements, followed by a ".space" directive to reserve 20-30 byte spaces (extra room in case you input a few extra characters, and so that you will still have a null-terminated string, since ".space" clears all byte spaces to 0). • Inputs the string from the keyboard using syscall 8 and places it in the space labeled "string 1." • Alphabetizes the string using a loop and outputs the alphabetized string to the simulated console. • Removes any characters that are not small letters (capitals, punctuation, numbers, etc.). • Outputs the ordered letters, preceded by a statement: "The alphabetized string is:
Answer:
Explanation:
find the attached below
P5. (5pts) Recall that we saw the Internet checksum being used in both transport-layer segment (in UDP and TCP headers) and in network-layer datagrams (IP header). Now consider a transport layer segment encapsulated in an IP datagram. Are the checksums in the segment header and datagram header computed over any common bytes in the IP datagram
Answer:
see explaination
Explanation:
No common bytes are used to compute the checksum in the IP datagram. Only the IP header is used to compute the checksum at the network Layer.
At TCP/UDP segment, the IP datagram may have different protocol stacks used.
Therefore, when a TCP datagram is entered in the IP datagram, it is not necessary to use common byte to compute checksum.
The checksums in the transport-layer (TCP/UDP) and network-layer (IP) headers are computed over different sets of bytes, ensuring the integrity of their respective areas independently.
The IP header checksum covers only the IP header, while the TCP/UDP checksum includes their headers and data, along with some IP header information.
The checksums in the transport-layer segment (like TCP and UDP) and the network-layer datagram (IP) headers are designed to ensure data integrity by detecting errors that may have occurred during transmission.
However, the checksums are not computed over any common bytes of the IP datagram. The IP header checksum is computed exclusively over the IP header, which includes the source and destination IP addresses, protocol, and other fields. Conversely, the checksum for the TCP or UDP segment is computed over the entire segment, which includes the payload (data) and a pseudo-header. The pseudo-header contains certain fields from the IP header, like source and destination addresses, protocol, and segment length, but the checksum itself does not overlap with that of the IP header. Example:
If an IP datagram carries a TCP segment, the IP checksum will only ensure the integrity of the IP header.The TCP checksum ensures the integrity of the TCP header and its data.For each of the two questions below, decide whether the answer is (i) "Yes," (ii) "No," or (iii) "Unknown, because it would resolve the question of whether P = NP." Give a brief explanation of your answer. (a) Let’s define the decision version of the Interval Scheduling Prob- lem from Chapter 4 as follows: Given a collection of intervals on a time-line, and a bound k, does the collection contain a subset of nonoverlapping intervals of size at least k? Question: Is it the case that Interval Scheduling ≤P Vertex Cover? (b) Question: Is it the case that Independent Set ≤P Interval Scheduling?
Final answer:
The original student question pertains to computational complexity and the relationship between different problems within the NP complexity class, seeking to understand polynomial-time reductions between Interval Scheduling, Vertex Cover, and Independent Set.
Explanation:
The questions provided revolve around computational complexity, particularly the concepts surrounding the complexity classes P, NP, and the relations between different computational problems. Unfortunately, the rest of the information provided is not related to the P vs NP question raised and therefore not relevant for forming an answer to the question at hand. The original question seems to ask whether 'Interval Scheduling' can be polynomial-time reduced to 'Vertex Cover' (Interval Scheduling ≤P Vertex Cover), and whether 'Independent Set' can be polynomial-time reduced to 'Interval Scheduling' (Independent Set ≤P Interval Scheduling). These questions are seeking to understand the computational complexity relationship between different NP problems.
Server farms such as Google and Yahoo! provide enough compute capacity for the highest request rate of the day. Imagine that most of the time these servers operate at only 60% capacity. Assume further that the power does not scale linearly with the load; that is, when the servers are operating at 60% capacity, they consume 90% of maximum power. The servers could be turned off, but they would take too long to restart in response to more load. A new system has been proposed that allows for a quick restart but requires 20% of the maximum power while in this "barely alive" state. a. How much power savings would be achieved by turning off 60% of the servers? b. How much power savings would be achieved by placing 60% of the servers in the "barely alive" state? c. How much power savings would be achieved by reducing the voltage by 20% and frequency by 40%? d. How much power savings would be achieved by placing 30% of the servers in the "barely alive" state and 30% off?
Answer:
a) Power saving = 26.7%
b) power saving = 48%
c) Power saving = 61%
d) Power saving = 25.3%
Explanation:
To find all the prime numbers less than or equal to a given integer n by Eratosthenes' method: 1. Create a list of consecutive integers from two to n: (2, 3, 4, ..., n), 2. Initially, let p equal 2, the first prime number, 3. While enumerating all multiples of p starting from p2, strike them off from the original list, 4. Find the first number remaining on the list after p (it's the next prime); let p equal this number, 5. Repeat steps 3 and 4 until p2 is greater than n. 6. All the remaining numbers in the list are prime.
Answer:
I am writing a Python program:
def Eratosthenes(n):
primeNo = [True for i in range(n+1)] # this is a boolean array
p = 2 # the first prime number is initialized as 2
while (p * p <= n): # enumerates all multiples of p
if (primeNo[p] == True):
for i in range(p * p, n+1, p): #update multiples
primeNo[i] = False
p = p + 1
for p in range(2, n): #display all the prime numbers
if primeNo[p]:
print(p),
def main(): #to take value of n from user and display prime numbers #less than or equal to n by calling Eratosthenes method
n= int(input("Enter an integer n: "))
print("The prime numbers less than or equal to",n, "are: ")
Eratosthenes(n)
main()
Explanation:
The program contains a Boolean type array primeNo that is initialized by True which means that any value i in prime array will be true if i is a prime otherwise it will be false. The while loop keeps enumerating all multiples of p starting from 2, and striking them off from the original array list and for loops keep updating the multiples. This process will continue till the p is greater than n. The last for loop displays all the prime numbers less than or equal to n which is input by user. main() function prompts user to enter the value of integer n and then calls Eratosthenes() function to print all the prime numbers less than or equal to a given integer n.
Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has the date of an appointment, the month of an appointment, the year of an appointment, and the description of an appointment (e.g., "see the dentist"). In other words, four major instant variables in these classes. Then, write a method occcursOn(year, month, day) that checks whether the appointment occurs on that date. Ensure to have a test program to test your classes. In your test program, you should create a list of appointments using the concept of polymorphism as your appointment pool. In other words, creating multiple objects using your subclasses of Onetime, Daily, and Monthly. Once you have those appointments available, allow the user to input day, month, and year to check whether the day of the month matches and print out the information of that matched appointment. For example, for a monthly appointment, you must check whether the day of the month matches. Have the user enter a date and print out all appointments that occur on that date.
Final answer:
The question involves creating an appointment system in object-oriented programming, where a superclass 'Appointment' and its subclasses 'Onetime', 'Daily', and 'Monthly' are defined, each with a method to check if an appointment occurs on a specified date.
Explanation:
Implementing Appointment Superclass and Subclasses
To model an appointment system, we implement a superclass named Appointment with subclasses called Onetime, Daily, and Monthly. Each class contains instance variables for the date, month, year, and a description of the appointment. The key method, occursOn(year, month, day), determines if an appointment is scheduled for a specific date by checking the year, month, and day against the appointment's details.
Appointment Superclass
The superclass includes the four main instance variables and provides the foundational behavior for its subclasses.
Onetime, Daily, and Monthly Subclasses
The subclasses override the occursOn() method to provide specific checking logic for one-time, daily, and monthly appointments.
A test program can be created to instantiate different types of appointments and check if they occur on a user-input date. By utilizing polymorphism, we can maintain a list of appointments of various subclasses. The test program will iterate through this list, applying the occursOn() method to find and print out matching appointments for the given date.
a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata (which you must declare) to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do. Declare any variables that you need.
Answer:
See explaination for program code
Explanation:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
string name;
int age;
cout << "Enter name of user: ";
getline(cin, name);
cout << "Enter age of user: ";
cin >> age;
ofstream outdata("outdata");
outdata << name << " " << age << endl;
outdata.close();
return 0;
}
The Online Shopping system facilitates the customer to view the products, inquire about the product details, and product availability. It allows the customer to get register in order to purchase products. The customer can search products by browsing different product categories or by entering search keywords. Customer can place order and pay online. There are two acceptable payment methods. These are (1) pay by credit card and (2) pay by PayPal. The system provide service to seller to place the products for selling. The seller creates account to become the member and places his products under suitable product category. The systems allows the administrator to manage the products. It facilitates the administrator to modify the existing products categories or to add new products categories. The system facilitate site manager to view different reports including (1) order placed by customers, (2) products added by sellers, and (3) accounts created by users. Question 3.4.1 List software system actors. (10 points) Question 3.4.2 Write use cases associated with each stakeholder. (Note: each use case starts with an action word) (10 points)
Answer:
see explaination
Explanation:
We will consider the five Actors in the prearranged Online shopping software system:
Customer:
The scheme allows the customer to do below mention actions:
View goods and inquire about the niceties of products and their ease of use.
To create version to be able to purchase invention from the structure.
Browse crop through search category or shortest search alternative.
Place order for the necessary crop.
Make sum for the order(s) positioned.
Payment System:
Payment system allows client to pay using subsequent two methods:
Credit card.
PayPal.
Seller:
System allow seller to perform underneath actions:
Place the foodstuffs for selling under apposite product category.
Create account to happen to a member.
Administrator:
Following actions are perform by Admin:
Manage the goods posted in the system.
Modify existing manufactured goods categories or add novel categories for foodstuffs.
Site Manager:
System privileges Site director with the following role in the system:
View information on:
Orders Placed by customer
Products added by seller
Accounts created by users
check attachment
Yolanda lost her left foot during her military service, but she has been issued a prosthetic that enables her to walk normally, and if you didn't see this device, you wouldn't know that she was using it. This is an example of the way technology is a(n) __________ means of extending human abilities.
Answer:
The correct answer to the following question will be "Artificial and superficial".
Explanation:
Prosthetic is just an automated means of replacing or restoring the missing component, where Yolanda has missing her foot and sometimes a prosthetic leg has indeed been released that helps her to walk or stand normally and superficially, but once it is thoroughly investigated you wouldn't have seen Yolanda using this tool.And as such the specified situation seems to be an example of how innovation would be artificial as well as a superficial medium of human capacity expansion.What are the disadvantages of a Cessna 172?
Answer:
The 172 accounted for 17-percent of the active fleet and flew 16-percent of the hours flown while accounting for six-percent of the fatal accidents.
Explanation:
In a two-year period there was but one fatal 172 accident that was due to a mechanical failure. That was an engine failure related to a valve. There were no fatal accidents related to fuel exhaustion or starvation.
Despite the good record in that area, the 172 is probably involved in just as many forced landings as any like airplane. It just appears more adaptable to impromptu arrivals than some other airplanes. The low landing speed contributes to this. There is no available statistic on this, but I would bet that most 172 forced landings don’t result in what the NTSB classifies as an accident.
I looked at fatal 172 accidents that occurred during two more recent years (2012 and 2013) when virtually all the NTSB reports were final as opposed to preliminary. There were 25 such accidents in the 48 contiguous states. If the methodology I used years ago is applied to that number, the 172 safety record appears to have improved, maybe substantially.
1. Compare the similarities and differences between traditional computing and the computing clouds launched in recent years. Also discuss possible convergence of the two computing paradigms in the future.
2. An increasing number of organizations in industry and business adopt cloud systems. Answer the following questions regarding cloud computing:
a. List and describe the main characteristics of cloud computing systems.
b. Discuss key enabling technologies in cloud computing systems.
c. Discuss different ways for cloud service providers to maximize their revenues.
d. Characterize the three cloud computing models using suitable examples.
Answer and explanation:
(1)
Resilience and Elasticity
The information and applications hosted in the cloud are evenly distributed across all the servers, which are connected to work as one. Therefore, if one server fails, no data is lost and downtime is avoided. The cloud also offers more storage space and server resources, including better computing power. This means your software and applications will perform faster.
Flexibility and Scalability
Cloud hosting offers an enhanced level of flexibility and scalability in comparison to traditional data centres. The on-demand virtual space of cloud computing has unlimited storage space and more server resources. Cloud servers can scale up or down depending on the level of traffic your website receives, and you will have full control to install any software as and when you need to. This provides more flexibility for your business to grow.
Automation
A key difference between cloud computing and traditional IT infrastructure is how they are managed. Cloud hosting is managed by the storage provider who takes care of all the necessary hardware, ensures security measures are in place, and keeps it running smoothly. Traditional data centres require heavy administration in-house, which can be costly and time consuming for your business. Fully trained IT personnel may be needed to ensure regular monitoring and maintenance of your servers – such as upgrades, configuration problems, threat protection and installations.
Running Costs
Cloud computing is more cost effective than traditional IT infrastructure due to methods of payment for the data storage services. With cloud based services, you only pay for what is used – similarly to how you pay for utilities such as electricity. Furthermore, the decreased likelihood of downtime means improved workplace performance and increased profits in the long run.
Security
Cloud computing is an external form of data storage and software delivery, which can make it seem less secure than local data hosting. Anyone with access to the server can view and use the stored data and applications in the cloud, wherever internet connection is available. Choosing a cloud service provider that is completely transparent in its hosting of cloud platforms and ensures optimum security measures are in place is crucial when transitioning to the cloud.
2(a)The five main characteristics of cloud computing systems are given below:
On-demand self-service: That is used when needed
Broad network access: That is ubiquitous, that is, it is everywhere
Multi-tenancy and resource pooling: That is sharing of resources
Rapid elasticity and scalability : Deploy only the amount of resources needed at a time
Measured service: Pay for what you use
(b)The five key enabling technologies in cloud computing systems are given below:
Client server using Application Control Interfaces Server Virtualization : Allows platform independence sort of scenario. Aggregation of computers into server based data centers: I.e high availability of computing resources Storage technologies supporting logical shards: Replication and safety of data Network virtualization(c). The three different ways for cloud service providers to maximize their revenues:
Development : Here the revenue comes from subscriptions paid by the customers.These also testing a new market for development.
Reselling : Using a pre-developed service or a cloud-based application- if it works really well. Then it can be ported to an on-premises solution thus bringing is a large possibility of prospective consumers.These also testing a new market for deployment.
Hosting: Server hardware is very expensive thus cloud computing is marketed as a good solution for disaster recovery solutions for customer data and profits are made as per subscription or dynamic virtual resource renting approach
(d)The characteristics of three cloud computing models using suitable examples is given below:
IAAS: This provides virtualized computing resources over cloud i.e over the internet. Here the cloud provider will host the infrastructure components which are traditionally present in an on-premises data center, hardware,servers etc. For example: Google Compute Engine, Linode
PAAS: This usually provides a platform as a service which allows the customers to develop, run, and manage applications. The users do not have to undergo the the complexity of building and maintaining the infrastructure which is typically associated with developing and launching an app if they are using a PAAS. Examples are AWS Elastik beanstalk, Apache Stratos
SAAS:In this model model the customer is provided with access to application software which is often referred to as "on-demand software". For example Google Drive, PayPal etc
Similarities and differences in computing.
Computing is the goal, oriented activity that needs benefits from creating the computing machinery that helps is study and measuring the algorithms process of development. Traditional and cloud-based computing refers to the delivery of services through data and the program on the internet.
Thus the answer is technology, security, infrastructure.
The difference is related to the local servers and the cloud or internet system. The convergence of the two technologies show the dynamic possibilities for the future of the technology leads to enhanced security and information maintenance. The provision of further technology of switches and routers.The increase in the number of organizations and businesses over the recent years has led to the growth of cloud computing and many services related to the international domain.This has led to the growth of technology and infrastructure.
Learn more about the compare the similarities.
brainly.com/question/24507709.
2. Consider the two-dimensional array A: int A[][] = new int[100][100]; where A[0][0] is at location 200 in a paged memory system with pages of size 200. Asmall process that manipulates the matrix resides in page 0 (locations 0 to 199). Thus, every instruction fetch will be from page 0. For three page frames, how many page faults are generated by the following array-initialization loops? Use LRU replacement, and assume that page frame 1 contains the process and the other two are initially empty. a. for (int j = 0; j < 100; j++) for (int i = 0; i < 100; i++) A[i][j] = 0; b. for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) A[i][j] = 0;
Final answer:
The problem is about calculating the number of page faults for two different loop orderings in a paged memory system under LRU replacement. Loop (a) has a column-major ordering, likely causing a new page fault for each new column accessed, while loop (b) has a row-major ordering, causing fewer page faults due to contiguous memory access.
Explanation:
A student has asked about the number of page faults generated by array-initialization loops in a paged memory system, specific to a given scenario with LRU replacement policy. We have two different loop orderings to consider with three page frames available.
For the first loop (part a), which is column-major order:
Page fault will occur for each new column since each element of a column is on a different page (due to row-major storage in C-like languages).
There are 100 columns, so initially, we will have 100 page faults for the first 100 pages.
As pages are brought into memory and replaced using LRU, subsequent accesses to those pages within the loop may not cause additional faults if they remain in the frame.
For the second loop (part b), which is row-major order:
Since each row is contiguous in memory, fewer page faults will occur.
The loop accesses 200 int elements before moving to a new page, thus causing a page fault.
We can fill two page frames with array data since one frame is occupied by the process.
During routine maintenance on your server, you discover that one of the hard drives on your RAID array is starting to go bad. After you replace the drive and rebuild the data, you run diagnostics on the RAID controller card with no problems, so you believe you fixed the problem. The next morning you arrive at work and discover that the RAID has completely failed. None of the disks are working. Your server is still running because you installed the OS on a non-RAID disk, but all the data is missing, and the server shows that none of your RAID disks are found.What might be the problem with your server? (Select all that apply.)asked Aug 13, 2019 in Computer Science & Information Technology by fili1001A. MotherboardB. CPUC. RAMD. RAID controllerE. Power supply
Answer:
RAID controller or Motherboard ie. A and D
Explanation:
From the explaination on the question the two most likely system parts that may be affecting the server are the Raid controller and the Motherboard.
The raid controller, this is because after the other drive has been replaced, the Raid still failed, it needs to be checked properly and replaced.
The motherboard, this is because it is the core centre of all boards.
Verify each computer in the LAN can ping the other computers. Also verify that each computer can ping the routerÕs gateway IP address [10.10.20.250]. If any of the assigned IP addresses fail to generate a reply, troubleshoot and correct the problem(s) until all devices can ping each other.
Answer:
The difficulty arises when your computer asks for an IP address and no one responds.
Whether due to a network problem — maybe not being on a network at all — or perhaps a lack of DHCP server to hand out IP addresses, the result is the same: the request for an IP address assignment goes unanswered.
Your machine waits for a while and then gives up.
But when it gives up, it invokes what’s called Automatic Private IP Addressing, or APIPA, and makes up its own IP address. And those “made up” IP addresses all begin with 169.254.
Limited connectivity
Situations resulting in a 169.254.x.x IP address are flagged as “limited connectivity” in Windows.
If you see that status associated with your network connectivity, then you’re facing the problem discussed here. Your machine almost certainly has a 169.254.x.x IP address.
Explanation:
JAVA
In this exercise, you are given a word or phrase and you need to return that word or phrase with the word ‘like’ in front of it.
If the phrase already starts with like, you should not add another one, just return the phrase as is.
Example:
like("totally awesome") --> "like totally awesome"
like("like cool dude") --> "like cool dude"
like("I like you") -->"like I like you"
Answer:
Answer in the screenshot provided.
Explanation:
Check if the String starts with like. If it does not then prepend it.
Write a program that will open a file named thisFile.txt and write every other line into the file thatFile.txt. Assume the input file (thisFile.txt) resides in the same directory as your code file, and that your output file (thatFile.txt) will reside in the same location. Do not attempt to read from or write to other locations.
Answer:
Check the explanation
Explanation:
The programmable code to solve the question above will be written in a python programming language (which is a high-level, interpreted, general-purpose programming language.)
f = open('thisFile.txt', 'r')
w = open('thatFile.txt', 'w')
count = 0
for line in f:
if count % 2 == 0:
w.write(line)
count += 1
w.close()
f.close()
The idea is to simulate random (x, y) points in a 2-D plane with domain as a square of side 1 unit. Imagine a circle inside the same domain with same diameter and inscribed into the square. We then calculate the ratio of number points that lied inside the circle and total number of generated points.
Answer:
For calculating Pi (π), the first and most obvious way is to measure the circumference and diameter.
π = Circumference / diameter
For the random points in the 2-D plane, we calculate the ratio of number points inside the circle and generate random pairs and then check
x² + y² < 1
If the given condition is true, then increment the points and used them. In randomized and simulation algorithms like Monte Carlo. In this case, if the number of the iteration is more then more accurate, the result is.
Explanation:
For simulating the random points in 2-D using Monte Carlo algorithms:
Monte Carlo
In this algorithm, we calculate the ratio of the number of points that lied in the circle. We do not need any graphics or simulations to generated points. In this, we generate random pairs and check x² + y² < 1.
π ≅ 4 × N inner / N total
The other way for calculating Pi (π) is to use Gregory-Leibniz Series.
Series which converges more quickly is Nilakangtha Series, which is developed in the 15th century. It is the other way to calculate Pi (π).
Your task is to break a number into its individual digits, for example, to turn 1729 into 1, 7, 2, and 9. It is easy to get the last digit of a number n as n % 10. But that gets the numbers in reverse order. Solve this problem with a stack. Your program should ask the user for an integer, then print its digits separated by spaces.
Answer:
stack = []
number = int(input("Enter a number: "))
while number > 0:
stack.append(number % 10)
number = int(number / 10)
while len(stack) > 0:
print(stack.pop(), end=" ")
Explanation:
Initialize an empty list to represent the stack
Get a number from the user
Create a while loop that iterates through the given number and append its last digit to stack
When the first loop is done, your stack is filled with the digits of the given number
Create another while loop that iterates through your stack and prints its elements, digits of the number, separated by spaces
What is required for real-time surveillance of a suspects computer activity?/p Group of answer choices a. Blocking data transmissions between a suspect’s computer and a network server. b. Poisoning data transmissions between a suspect’s computer and a network server. c. Preventing data transmissions between a suspect’s computer and a network server. d. Sniffing data transmissions between a suspect’s computer and a network server.
Answer:
c Preventing data transmissions between a suspect’s computer and a network server
Explanation:
Select the correct statement(s) regarding CATV. a. CATV began as a broadcast capability over shared coaxial cable medium; as such, security issues are a concern b. CATV DOCSIS systems rely on QPSK and QAM modulation c. today’s CATV system uses a combination of fiber optic and coaxial cable d. all statements are correct
Answer:
d. all statements are correct
Explanation:
CATV is a very common method used in transmitting television signal to homes, this is achieved through the use of radio frequency signals which is transmitted via coaxial cable. In recent times, CATV as been transmitted through optical fiber, this optical fiber makes use of light to transmit signal.
CATV can be traced back to 1924 in which cable broadcasting was done through the use cable in Europe.
please identify three examples of how the United States is heteronormative
Final answer:
Heteronormativity in U.S. society is evident in legal recognition of heterosexual marriages, social expectations based on traditional gender roles, and media representations that prioritize heterosexual relationships.
Explanation:
Heteronormativity refers to the assumption that heterosexual orientation is the norm and other sexual orientations are considered abnormal. Here are three examples of how U.S. society is heteronormative:
Legal recognition: The U.S. government and many states have historically only recognized heterosexual marriages, excluding same-sex couples from legal recognition and benefits.Social expectations: Traditional gender roles and expectations often assume a heterosexual orientation, such as the expectation that a man and a woman will marry and have children.Media representations: Mainstream media tends to overwhelmingly portray heterosexual relationships as the default, downplaying or erasing the existence of LGBTQ+ relationships.These examples demonstrate how heteronormativity privileges and normalizes heterosexual orientations while marginalizing and stigmatizing non-heterosexual orientations.