Answer:
/etc/yum.conf
Explanation:
The absolute pathname for YUM is /etc/yum.conf. The configuration file For yum and related utilities can be found there. The file has one compulsory section, and this section can be used to place Yum options with global effect, it could also have one or more sections, that can enable you to set repository-specific options.
Write a program that prompts the user for the name of two files each containing a single line that represents a decimal integercall them m and n, keep in mind that theseintegerscould be very largein absolute value, so they might not be stored neither as along nor intvariables. You should:a)Handle erroneous input graciously.b)Include a class named BigIntegerwhere you define an integer as a linked list, along with integer operations such as addition and subtraction [multiplication and division will grant you extra points] c)Test your program for each operation and store the result of each operation as a single decimal number in a separate file containing only one line\
Answer:
The output is seen bellow
Explanation:
public class BigInteger {
public class Node{
private char data;
private Node next;
public Node(char d){
this.setData(d);
this.setNext(null);
}
public char getData() {
return data;
}
public void setData(char data) {
this.data = data;
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}
}
private Node root;
public BigInteger(String s){
this.root=null;
for(int i=s.length()-1;i>=0;i--){
Node node=new Node(s.charAt(i));
node.setNext(root);
root=node;
}
}
public String toString(){
String str="";
Node cur=this.root;
int i=0;
while(cur!=null){
if(i==0 && cur.getData()=='0'){
}
else{
i=1;
str+=cur.getData();
}
cur=cur.getNext();
}
return str;
}
public String reverse(String s){
String ret="";
for(int i=s.length()-1;i>=0;i--){
ret+=s.charAt(i);
}
return ret;
}
public BigInteger add(BigInteger s){
String f=this.reverse(this.toString());
String l=this.reverse(s.toString());
int max=(f.length()>l.length())?f.length():l.length();
String ret="";
int carry=0;
for(int i=0;i<max;i++){
int sum=carry;
if(i<f.length()){
sum+=(f.charAt(i)-'0');
}
if(i<l.length()){
sum+=(l.charAt(i)-'0');
}
ret+=(char)(sum%10+'0');
carry=(sum/10);
}
if(carry!=0){
ret+='1';
}
BigInteger bi=new BigInteger(this.reverse(ret));
return bi;
}
public boolean bigNum(String s1,String s2){
if(s1.length()>s2.length()){
return true;
}
else{
if(s1.length()<s2.length()){
return false;
}
else{
for(int i=0;i<s1.length();i++){
if(s1.charAt(i)!=s2.charAt(i)){
if(s1.charAt(i)>s2.charAt(i)){
return true;
}
else{
return false;
}
}
}
}
}
return false;
}
public BigInteger subtraction(BigInteger s){
String f=this.toString();
String l=s.toString();
boolean b=this.bigNum(f, l);
if(b==false){
String tmp=f;
f=l;
l=tmp;
}
f=this.reverse(f);
l=this.reverse(l);
int max=(f.length()>l.length())?f.length():l.length();
String ret="";
int borrow=0;
for(int i=0;i<max;i++){
int sum=borrow;
if(i<f.length()){
sum+=(f.charAt(i)-'0');
}
if(i<l.length()){
sum-=(l.charAt(i)-'0');
}
if(sum<0){borrow=-1;sum=10+sum;}
else{borrow=0;}
ret+=(char)(sum%10+'0');
}
if(b==false){
ret+="-";
}
BigInteger bi=new BigInteger(this.reverse(ret));
return bi;
}
public BigInteger multiplication(BigInteger s){
String f=this.toString();
String l=s.toString();
int len=l.length();
BigInteger bi=new BigInteger("");
for(int i=len-1;i>=0;i--){
//System.out.println(l.charAt(i));
BigInteger r=new BigInteger(f);
for(int j=(l.charAt(i)-'0');j>1;j--){
r=r.add(new BigInteger(f));
//System.out.print(r+" " );
}
//System.out.println();
bi=bi.add(r);
f=f+"0";
}
return bi;
}
public BigInteger division(BigInteger s){
BigInteger t=this;
BigInteger bi=new BigInteger("");
int i=0;
t=t.subtraction(s);
String str=t.toString();
while(str.charAt(0)!='-' && i<40){
//System.out.println(str+" "+(i+1));
bi=bi.add(new BigInteger("1"));
t=t.subtraction(s);
str=t.toString();
i++;
}
return bi;
}
}
-------------------
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Driver {
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
String str1="";
String str2="";
System.out.print("Enter file name 1 :");
String file1=sc.next();
//String file1="datafile1.txt";
BufferedReader reader1;
try {
reader1 = new BufferedReader(new FileReader(file1));
while((str1=reader1.readLine())!=null){
break;
}
reader1.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("Enter file name 2 :");
String file2=sc.next();
//String file2="datafile2.txt";
BufferedReader reader2;
try {
reader2 = new BufferedReader(new FileReader(file2));
while((str2=reader2.readLine())!=null){
break;
}
reader2.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Use the loop invariant (I) to show that the code below correctly computes the product of all elements in an array A of n integers for any n ≥ 1. First use induction to show that (I) is indeed a loop invariant, and then draw conclusions for the termination of the while loop.
Algorithm 1 computeProduct(int[ ] A, int n)
p = a[0]
i = 0
while i < n − 1 do
//(I) p = a[0] · a[1] · · · a[i] (Loop Invariant)
i + +
p = p · a[i]
end while
return p
Answer:
Given Loop Variant P = a[0], a[1] ... a[i]
It is product of n terms in array
Explanation:
The Basic Step: i = 0, loop invariant p=a[0], it is true because of 'p' initialized as a[0].
Induction Step: Assume that for i = n - 3, loop invariant p is product of a[0], a[1], a[2] .... a[n - 3].
So, after that multiply a[n - 2] with p, i.e P = a[0], a[1], a[2] .... a[n - 3].a[n - 2].
After execution of while loop, loop variant p becomes: P = a[0], a[1], a[2] .... a[n -3].a[n -2].
for the case i = n-2, invariant p is product of a[0], a[1], a[2] .... a[n-3].a[n-2]. It is the product of (n-1) terms. In while loop, incrementing the value of i, so i=n-1
And multiply a[n-1] with p, i.e P = a[0].a[1].a[2].... a[n-2].
a[n-1]. i.e. P=P.a[n-1]
By the assumption for i=n-3 loop invariant is true, therefore for i=n-2 also it is true.
By induction method proved that for all n > = 1 Code will return product of n array elements.
While loop check the condition i < n - 1. therefore the conditional statement is n - i > 1
If i = n , n - i = 0 , it will violate condition of while loop, so, the while loop will terminate at i = n at this time loop invariant P = a[0].a[1].a[2]....a[n-2].a[n-1]
Do Exercise 6.4 from your textbook using recursion and the is_divisible function from Section 6.4. Your program may assume that both arguments to is_power are positive integers. Note that the only positive integer that is a power of "1" is "1" itself. After writing your is_power function, include the following test cases in your script to exercise the function and print the results: print("is_power(10, 2) returns: ", is_power(10, 2)) print("is_power(27, 3) returns: ", is_power(27, 3)) print("is_power(1, 1) returns: ", is_power(1, 1)) print("is_power(10, 1) returns: ", is_power(10, 1)) print("is_power(3, 3) returns: ", is_power(3, 3))
Answer:
Here is the python method:
def is_power(n1, n2): # function that takes two positive integers n1 and n2 as arguments
if(not n1>0 and not n2>0): #if n1 and n2 are not positive integers
print("The number is not a positive integer so:") # print this message if n1 and n2 are negative
return None # returns none when value of n1 and n2 is negative.
elif n1 == n2: #first base case: if both the numbers are equal
return True #returns True if n1=n2
elif n2==1: #second base case: if the value of n2 is equal to 1
return False #returns False if n2==1
else: #recursive step
return is_divisible(n1, n2) and is_power(n1/n2, n2) #call divisible method and is_power method recursively to determine if the number is the power of another
Explanation:
Here is the complete program.
def is_divisible(a, b):
if a % b == 0:
return True
else:
return False
def is_power(n1, n2):
if(not n1>0 and not n2>0):
print("The number is not a positive integer so:")
return None
elif n1 == n2:
return True
elif n2==1:
return False
else:
return is_divisible(n1, n2) and is_power(n1/n2, n2)
print("is_power(10, 2) returns: ", is_power(10, 2))
print("is_power(27, 3) returns: ", is_power(27, 3))
print("is_power(1, 1) returns: ", is_power(1, 1))
print("is_power(10, 1) returns: ", is_power(10, 1))
print("is_power(3, 3) returns: ", is_power(3, 3))
print("is_power(-10, -1) returns: ", is_power(-10, -1))
The first method is is_divisible method that takes two numbers a and b as arguments. It checks whether a number a is completely divisible by number b. The % modulo operator is used to find the remainder of the division. If the remainder of the division is 0 it means that the number a is completely divisible by b otherwise it is not completely divisible. The method returns True if the result of a%b is 0 otherwise returns False.
The second method is is_power() that takes two numbers n1 and n2 as arguments. The if(not n1>0 and not n2>0) if statement checks if these numbers i.e. n1 and n2 are positive or not. If these numbers are not positive then the program prints the message: The number is not a positive integer so. After displaying this message the program returns None instead of True of False because of negative values of n1 and n2.
If the values of n1 and n2 are positive integers then the program checks its first base case: n1 == n2. Suppose the value of n1 = 1 and n2 =1 Then n1 is a power of n2 if both of them are equal. So this returns True if both n1 and n2 are equal.
Now the program checks its second base case n2 == 1. Lets say n1 is 10 and n2 is 1 Then the function returns False because there is no positive integer that is the power of 1 except 1 itself.
Now the recursive case return is_divisible(n1, n2) and is_power(n1/n2, n2) calls is_divisible() method and is_power method is called recursively in this statement. For example if n1 is 27 and n2 is 3 then this statement:
is_divisible(n1, n2) returns True because 27 is completely divisible by 3 i.e. 27 % 3 = 0
is_power(n1/n2,n2) is called. This method will be called recursively until the base condition is reached. You can see it has two arguments n1/n2 and n2. n1/n2 = 27/3 = 9 So this becomes is_power(9,3)
The base cases are checked. Now this else statement is again executed return is_divisible(n1, n2) and is_power(n1/n2, n2) as none of the above base cases is evaluated to true. when is_divisible() returns True as 9 is completely divisible by 3 i.e. 9%3 =0 and is_power returns (9/3,3) which is (3,3). So this becomes is_power(3,3)
Now as value of n1 becomes 3 and value of n2 becomes 3. So the first base case elif n1 == n2: condition now evaluates to true as 3=3. So it returns True. Hence the result of this statement print("is_power(10, 2) returns: ", is_power(10, 2)) is:
is_power(27, 3) returns: True
Following are the program to the given question:
Program Explanation:
Defining a method "is_divisible" that takes two variable "a,b" inside the parameter.Usinge the return keyword that modulas parameter value and checks its value equal to 0, and return its value.In the next step, another method "is_power" is declared that takes two parameter "a,b".Inside the method, a conditional statement is declared, in which three if block is used. Inside the two if block it checks "a, b" value that is "odd number" and return bool value that is "True, False".In the last, if block is used checks "is_power" method value, and use multiple print method to call and prints its value.Program:
def is_divisible(a, b):#defining a method is_divisible that takes two parameters
return a % b == 0#using return keyword that modulas parameter value and checks its value equal to 0
def is_power(a, b):#defining a method is_power that takes two parameters
if a == 1:#defining if block that checks a value equal to 1 or check odd number condition
return True#return value True
if b == 1:#defining if block that checks b value equal to 1 or check odd number condition
return False#return value False
if not is_divisible(a, b):#defining if block that check method is_divisible value
return False##return value False
return is_power(a/b, b)#using return keyword calls and return is_power method
print("is_power(10, 2) returns: ", is_power(10, 2))#using print method that calls is_power which accepts two parameter
print("is_power(27, 3) returns: ", is_power(27, 3))#using print method that calls is_power which accepts two parameter
print("is_power(1, 1) returns: ", is_power(1, 1))#using print method that calls is_power which accepts two parameter
print("is_power(10, 1) returns: ", is_power(10, 1))#using print method that calls is_power which accepts two parameter
print("is_power(3, 3) returns: ", is_power(3, 3))#using print method that calls is_power which accepts two parameter
Output:
Please find the attached file.
Learn more:
brainly.com/question/24432065
3.16 (Gas Mileage) Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls. Here is a sample input/output dialog:
Answer:
I am writing a C program.
#include <stdio.h> // for using input output functions
#include <stdbool.h> // for using a bool value as data type
int main() { // start of the main() function body
int count=0; //count the number of entries
double gallons, miles, MilesperGallon, combined_avg, sum; //declare variables
while(true) {// takes input gallons and miles value from user and computes avg miles per gallon
printf( "Enter the gallons used (-1 to stop): \n" ); //prompts user to enter value of gallons or enter -1 to stop
scanf( "%lf", &gallons );//reads the value of gallons from user
if ( gallons == -1 ) {// if user enters -1
combined_avg = sum / count; //displays the combined average by dividing total of miles per drives to no of entries
printf( "Combined miles per gallon for all tankfuls: %lf\n", combined_avg ); //displays overall average value
break;} //ends the loop
printf( "Enter the miles driven: \n" ); //if user does not enter -1 then prompts the user to enter value of miles
scanf( "%lf", &miles ); //read the value of miles from user
MilesperGallon = miles / gallons; //compute the miles per gallon
printf( "The miles per gallon for tankful: %lf\n", MilesperGallon ); //display the computed value of miles per gallon
sum += MilesperGallon; //adds all the computed miles per gallons values
count += 1; } } //counts number of tankfuls (input entries)
Explanation:
The program takes as input the miles driven and gallons used for each tankful. These values are stored in miles and gallons variables. The program calculates and displays the miles per gallon MilesperGallon obtained for each tankful by dividing the miles driven with the gallons used. The while loop continues to execute until the user enters -1. After user enters -1, the program calculates and prints the combined miles per gallon obtained for all tankful. At the computation of MilesperGallon for each tankful, the value of MilesperGallon are added and stored in sum variable. The count variable works as a counter which is incremented to 1 after each entry. For example if user enters values for miles and gallons and the program displays MilesperGallon then at the end of this iteration the value of count is incremented to 1. This value of incremented for each tankful and then these values are added. The program's output is attached.
5- The Menu key or Application key is
A. is the placements and keys of a keyboard.
B. a telecommunications technology used to transfer copies of documents
c. a key found on Windows-oriented computer keyboards.
Answer:
c. a key found on Windows-oriented computer keyboards.
Explanation:
Hope it helps.
Consider a classful IPv4 address 200.200.200.200? What is its implied subnet mask? If we take the same address and append the CIDR notation "/27", now what is its subnet mask?
Answer:
a. 255.255.255.0 (class C)
b. 255.255.255.224
Explanation:
Here, we want to give the implied subnet mask of the given classful IPV4 address
We proceed as follows;
Given IPv4 address: 200.200.200.200
Classes
Class A : 0.0.0.0 to 127.255.255.255
Class B: 128.0.0.0 to 191.255.255.255
Class C: 192.0.0.0 to 223.255.255.255
Class D: 224.0.0.0 to 239.255.255.255
so 200.200.200.200 belongs to Class C and it's subnet mask is 255.255.255.0
In CIDR(Classless Inter Domain Routing)
subnet /27 bits means 27 1s and 5 0s. so subnet
i.e 11111111.11111111.11111111.11100000 which in dotted decimal format is 255.255.255.224 .
A program is considered portable if it . . . can be rewritten in a different programming language without losing its meaning. can be quickly copied from conventional RAM into high-speed RAM. can be executed on multiple platforms. none of the above
Answer:
Can be executed on multiple platforms.
Explanation:
A program is portable if it is not platform dependent. In other words, if the program is not tightly coupled to a particular platform, then it is said to be portable. Portable programs can run on multiple platforms without having to do much work. By platform, we essentially mean the operating system and hardware configuration of the machine's CPU.
Examples of portable programs are those written in;
i. Java
ii. C++
iii. C
What is the value of the variable named myNum after the statements that follow are executed? var myNum = 14; var yourNum = 4; myNum++; yourNum-- myNum = myNum * yourNum;
Answer:
45
Explanation:
Initially, myNum is equal to 14 and yourNum is equal to 4
Then, myNum is incremented by 1 and becomes 15
Also, yourNum is decremented by 1 and becomes 3
Finally, myNum is set to myNum x yourNum, 15 x 3 = 45
Alcatel-Lucent’s High Leverage Network (HLN) increases bandwidth and network capabilities while reducing the negative impact on the environment. HLN can handle large amounts of traffic more efficiently because __________.
Answer:
The networks are intelligent and send packets at the highest speed and most efficiently.
Explanation:
Alcatel-Lucent was founded in 1919, it was a French global telecommunications equipment manufacturing company with its headquarter in Paris, France. Alcatel-Lucent provide services such as telecommunications and hybrid networking solutions deployed both in the cloud and on properties.
Alcatel-Lucent’s High Leverage Network (HLN) increases bandwidth and network capabilities while reducing the negative impact on the environment. This high leverage network can handle large amounts of traffic more efficiently because the networks are intelligent and send packets at the highest speed and most efficiently. HLN are intelligent such that it delivers increased bandwidth using fewer devices and energy.
Generally, when the High Leverage Network (HLN) is successfully implemented, it helps telecommunications companies to improve their maintenance costs, operational efficiency, enhance network performance and capacity to meet the bandwidth demands of their end users.
A cache has been designed such that it has 512 lines, with each line or block containing 8 words. Identify the line number, tag, and word position for the 20-bit address 94EA616 using the direct mapping method.
Answer:
Given address = 94EA6[tex]_{16}[/tex]
tag = 0 * 94 ( 10010100 )
line = 0 * 1 D 4 ( 111010100 )
word position = 0*6 ( 110 )
Explanation:
using the direct mapping method
Number of lines = 512
block size = 8 words
word offset = [tex]log ^{8} _{2}[/tex] = 3 bit
index bit = [tex]log^{512}_{2}[/tex] = 9 bit
Tag = 20 - ( index bit + word offset ) = 20 - ( 3+9) = 8 bit
Given address = 94EA6[tex]_{16}[/tex]
tag = 0 * 94 ( 10010100 )
line = 0 * 1 D 4 ( 111010100 )
word position = 0*6 ( 110 )
LAB: Max magnitude. Sections: 2.8, 4.2, 6.7.
Write a function max_magnitude() with two integer input parameters that returns the largest magnitude value. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value.
Your program must define and call the following function:
def max_magnitude(user_val1, user_val2)
Ex: If the inputs are:
5 7
the function returns:
7
Ex: If the inputs are:
-8 -2
the function returns:
-8
****IN PYTHON******
Answer:
The program written in python is as follows:
import math
def max_magnitude(user_val1, user_val2):
if abs(user_val1)>abs(user_val2):
return user_val1
else:
return user_val2
val1 = int(input("Value 1: "))
val2 = int(input("Value 2: "))
print(max_magnitude(val1,val2))
Explanation:
This line imports the math module in the program
import math
This line declares the function with two parameters
def max_magnitude(user_val1, user_val2):
The if condition gets the absolute value of both integers and compares them; The integer with greater magnitude is returned, afterwards
if abs(user_val1)>abs(user_val2):
return user_val1
else:
return user_val2
The main method starts here
The next two lines prompt user for input
val1 = int(input("Value 1: "))
val2 = int(input("Value 2: "))
This line gets the integer with higher magnitude
print(max_magnitude(val1,val2))
#Imagine you're writing some code for an exercise tracker. #The tracker measures heart rate, and should display the #average heart rate from an exercise session. # #However, the tracker doesn't automatically know when the #exercise session began. It assumes the session starts the #first time it sees a heart rate of 100 or more, and ends #the first time it sees one under 100. # #Write a function called average_heart_rate. #average_heart_rate should have one parameter, a list of #integers. These integers represent heart rate measurements #taken 30 seconds apart. average_heart_rate should return #the average of all heart rates between the first 100+ #heart rate and the last one. Return this as an integer #(use floor division when calculating the average). # #You may assume that the list will only cross the 100 beats #per minute threshold once: once it goes above 100 and below #again, it will not go back above.
Answer:
Following are the code to this question:
def average_heart_rate(beats):#defining a method average_heart_rate that accepts list beats
total=0 #defining integer variable total,that adds list values
count_list=0#defining a count_list integer variable, that counts list numbers
for i in beats:#defining for loop to add list values
if i>= 100:#defining if block to check value is greater then 100
total += i#add list values
count_list += 1# count list number
return total//count_list #return average_heart_rate value
beats=[72,77,79,95,102,105,112,115,120,121,121,125, 125, 123, 119, 115, 105, 101, 96, 92, 90, 85]#defining a list
print("The average heart rate value:",average_heart_rate(beats)) # call the mnethod by passing value
Output:
The average heart rate value: 114
Explanation:
In the given question some data is missing so, program description can be defined as follows:
In the given python code, the method "average_heart_rate" defined that accepts list "beats" as the parameter, inside the method two-variable "total and count_list " is defined that holds a value that is 0.In the next line, a for loop is that uses the list and if block is defined that checks list value is greater then 100. Inside the loop, it calculates the addition and its count value and stores its values in total and count_list variable, and returns its average value.Similar to Wi-Fi, ____ is designed to provide internet access to fixed locations (sometimes called hot zones), but the coverage is significantly larger
Answer:
WiMAX.
Explanation:
WiMAX is an acronym for Worldwide Interoperability for Microwave Access, it is a wireless communications which is primarily based on the IEEE 802.16 standards for creating Metropolitan Area Network (MAN) for the internet users.
Similar to Wi-Fi, WiMAX is designed to provide internet access to fixed locations (sometimes called hot zones), but the coverage is significantly larger.
WiMAX is capable of covering large metropolitan distance of several kilometers while Wi-Fi covers just a local (short) area measured in meters.
Generally, WiMAX was invented by the WiMAX forum and is a telecommunications standard protocol that provides fixed and fully mobile internet access services over a wide range.
There is a colony of 8 cells arranged in a straight line where each day every cell competes with its adjacent cells(neighbour). Each day, for each cell, if its neighbours are both active or both inactive, the cell becomes inactive the next day,. otherwise itbecomes active the next day.
Assumptions: The two cells on the ends have single adjacent cell, so the other adjacent cell can be assumsed to be always inactive. Even after updating the cell state. consider its pervious state for updating the state of other cells. Update the cell informationof allcells simultaneously.
Write a fuction cellCompete which takes takes one 8 element array of integers cells representing the current state of 8 cells and one integer days representing te number of days to simulate. An integer value of 1 represents an active cell and value of 0 represents an inactive cell.
Program:
int* cellCompete(int* cells,int days)
{
//write your code here
}
//function signature ends
Test Case 1:
INPUT:
[1,0,0,0,0,1,0,0],1
EXPECTED RETURN VALUE:
[0,1,0,0,1,0,1,0]
Test Case 2:
INPUT:
[1,1,1,0,1,1,1,1,],2
EXPECTED RETURN VALUE:
[0,0,0,0,0,1,1,0]
This is the problem statement given above for the problem. The code which I have written for this problem is given below. But the output is coming same as the input.
#include
using namespace std;
// signature function to solve the problem
int *cells(int *cells,int days)
{ int previous=0;
for(int i=0;i
{
if(i==0)
{
if(cells[i+1]==0)
{
previous=cells[i];
cells[i]=0;
}
else
{
cells[i]=0;
}
if(i==days-1)
{
if(cells[days-2]==0)
{
previous=cells[days-1];
cells[days-1]=0;
}
else
{
cells[days-1]=1;
}
}
if(previous==cells[i+1])
{
previous=cells[i];
cells[i]=0;
}
else
{
previous=cells[i];
cells[i]=1;
}
}
}
return cells;
}
int main()
{
int array[]={1,0,0,0,0,1,0,0};
int *result=cells(array,8);
for(int i=0;i<8;i++)
cout<
}
I am not able to get the error and I think my logic is wrong. Can we apply dynamic programming here If we can then how?
Answer:
I am writing a C++ program using loops instead of nested if statements.
#include <iostream> // to use input output functions
using namespace std; // to identify objects like cin cout
void cells(int cells[],int days){ /* function that takes takes one array of integers cells, one integer days representing the number of days to simulate. */
int pos ,num=0; //declares variables pos for position of two adjacent cells and num to iterate for each day
int result[9]; //the updated output array
while (num< days) { //this loop keeps executing till the value of num is less than the value of number of days
num++;
for(pos=1;pos<9;pos++) //this loop has a pos variable that works like an index and moves through the cell array
result[pos]=(cells[pos-1])^ (cells[pos+1]); //updated cell state determined by the previous and next cells (adjacent cells) by bitwise XOR operations
for(pos=1;pos<9;pos++) //iterates through the array
cells[pos]=result[pos]; } //the updated cells state is assigned to the cell array simultaneously
for(pos=1;pos<9;pos++) //iterates through the array and prints the resultant array that contains the updated active and inactive cells values
cout << result[pos]; }
int main() { //start of the main function body
int j,day;
int output[9];
*/the two cells on the ends (first and last positions of array) have single adjacent cell, so the other adjacent cell can be assumed to be always inactive i.e. 0 */
output[0]=output[9]=0;
for(j=1;j<9;j++) //takes the input array from user
cin >> output[j];
cin >> day;
cells(output,day); } //calls the function cells to print the array with active and inactive cells states.
Explanation:
The program is well explained in the comments mentioned with every statement of the program. I will explain with the help of example:
Suppose the user enters the array = [1,0,0,0,0,1,0,0] and days=1
The while loop checks if the value of num is less than that of days. Here num is 0 and days is 1 So this means that the body of while loop will execute.
In the body of while loop the value of num is incremented by 1. The first loop initializes a variable pos for position of adjacent cells. The statement is a recursive statement result[pos]=(cells[pos-1])^ (cells[pos+1]) that uses previous state for updating the state of other cells. The “^” is the symbol used for bitwise exclusive operator. In bitwise XOR operations the two numbers are taken as operands and XOR is performed on every bit of two numbers. The result of XOR is 1 if the two bits are not same otherwise 0. For example XOR of 1^0 and 0^1 is 1 and the XOR of 0^0 and 1^1 is 0. The second for loop update the cell information of all cells simultaneously. The last loop prints the updated cells states.
The main function takes the input array element from user and the value for the days and calls the cells function to compute the print the active and inactive cells state information.
The screenshot of the program along with its output are attached.
Which tab group is used to modify the background of a chart that is contained in a PowerPoint presentation?
Chart styles
Data
Type
Chart layouts
Answer:
Chart styles
Explanation:
In PowerPoint, once you have inserted a chart (e.g a bar or pie chart), the format tab would be enabled so that you can format your chart to your taste. In this format tab, there are a bunch of tab groups such as:
(i) Chart styles: This allows you to typically change the component background colors of your chart.
(ii) Data: This contains sub-tabs that allow you to edit and select the data on your chart.
(iii) Type: This contains sub-tabs such as "Change Chart Type" which will allow you to change the type of the chart. For example if you were using a pie chart and you want to change it to a bar chart or any other chart, you can do that here.
(iv) Chart Layouts: This allows to change or modify how the selected chart is laid out.
Identify five key technologies/innovations and discuss their advantages and disadvantages to developing countries like Ghana.
Answer:
The key technology/ innovation advantage and disadvantage can be defined as follows:
Explanation:
Following are the 5 innovations and technology, which promote the other development goals, like renewable energy, quality of jobs, and growth of economic with the good health and very well-being:
1) The use of crop monitoring drone technology promotes sustainable farming.
2) The production of plastic brick including highways, floors, and houses.
3) The new banking market or digital banking.
4) E-commerce site.
5) Renewable energy deployment such as solar panels.
Advantage:
It simple insect control, disease, fertilizer, etc. It helps in aid in environmental purification and job formation.It is also fast and easy, Funds are transferred extremely easily through one account to another. Minimal prices, quick customer developments, and competition in the industry. It saves them money in the medium-haul, less servicing.Disadvantage:
The drones are too expensive to use, so poor farmers can be cut off. Specialist technicians and gaining popularity are required. The financial services data can be distributed through many devices and therefore become more fragile. The personal contact loss, theft, security problems, etc. The higher operating costs, geographical limitations, and so on.Oops, we made a mistake: we created a key "short" and gave it the value "tall", but we wanted to give it the value "long" instead. Write the line of code that will change the value associated with the key "short" to "long". Be consistent in whether you use single or double quotes to declare your strings: our autograder assumes you'll be consistent.
Answer:
Using java
//assuming that hashmap object name is ChangeMap
ChangeMap. replace("short", "long");
System.out.println("New HashMap: "
+ ChangeMap.toString());
Explanation:
From the above we have used the replace method to replace the value of the "short" key in the hashtable with "long" instead of the previous value "tall". We have used the printed the hashtable to the console using println and the ".toString()" method that we added to the function's parameter.
A user states that when they power on their computer, they receive a "Non-bootable drive" error. The user works with external storage devices to transport data to their computer. The user stated that the computer worked fine the day before. Which of the following should be checked FIRST to resolve this issue?
A. Jumper settings
B. Device boot order
C. PXE boot settings
D. Hard drive cable
Answer:
B. Device boot order
Explanation:
The Device boot order makes a list of all the possible devices a system should check to in the operating system's boot files, as well as the proper sequence they should be in. Removable devices, hard drives, and flash drives are some devices that can be listed in the device boot order.
For the user whose computer displays a 'non-bootable drive' error, the device boot order would check all the devices listed to attempt booting from any of them. These devices might be in the order of removable discs, CD-ROM, hard drive. If all the options do not work, the computer would then do a Network boot. The order in which the devices are listed can be altered by the user.
Write a function named word_count that accepts a string as its parameter and returns the number of words in the string. A word is a sequence of one or more non-space characters (any character other than ' ').
Answer:
def word_count(words):
return len(words.split(" "))
print(word_count("This is Python."))
Explanation:
*The code is in Python.
Create a function called word_count that takes one parameter, words
Split the words using split function, use " " for the delimiter, and return the length of this using len function.
Note that split function will give you a list of strings that are written with a space in the words. The len function will just give you the length of this list.
Call the word_count function with a string parameter and print the result.
Normally you depend on the JVM to perform garbage collection automatically. However, you can explicitly use ________ to request garbage collection.
Answer:
System.gc()
Explanation:
System.gc() can be defined as the method which can be used to effectively request for garbage collection because they runs the garbage collector, which in turn enables JMV which is fully known as JAVA VIRTUAL MACHINE to claim back the already unused memory space of the objects that was discarded for quick reuse of the memory space , although Java virtual machine often perform garbage collection automatically.
Use the following cell phone airport data speeds (Mbps) from a particular network. Find P10. 0.1 0.1 0.3 0.3 0.3 0.4 0.4 0.4 0.6 0.7 0.7 0.7 0.8 0.8
Answer:
[tex]P_{10} =0.1[/tex]
Explanation:
Given
[tex]0.1, 0.1, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.6, 0.7, 0.7, 0.7, 0.8, 0.8[/tex]
Required
Determine [tex]P_{10}[/tex]
[tex]P_{10}[/tex] implies 10th percentile and this is calculated as thus
[tex]P_{10} = \frac{10(n+1)}{100}[/tex]
Where n is the number of data; n = 14
[tex]P_{10} = \frac{10(n+1)}{100}[/tex]
Substitute 14 for n
[tex]P_{10} = \frac{10(14+1)}{100}[/tex]
[tex]P_{10} = \frac{10(15)}{100}[/tex]
Open the bracket
[tex]P_{10} = \frac{10 * 15}{100}[/tex]
[tex]P_{10} = \frac{150}{100}[/tex]
[tex]P_{10} = 1.5th\ item[/tex]
This means that the 1.5th item is [tex]P_{10}[/tex]
And this falls between the 1st and 2nd item and is calculated as thus;
[tex]P_{10} = 1.5th\ item[/tex]
Express 1.5 as 1 + 0.5
[tex]P_{10} = (1 +0.5)\ th\ item[/tex]
[tex]P_{10} = 1^{st}\ item +0.5(2^{nd} - 1^{st}) item[/tex]
From the given data; [tex]1st\ item = 0.1[/tex] and [tex]2nd\ item = 0.1[/tex]
[tex]P_{10} = 1^{st}\ item +0.5(2^{nd} - 1^{st}) item[/tex] becomes
[tex]P_{10} =0.1 +0.5(0.1 - 0.1)[/tex]
[tex]P_{10} =0.1 +0.5(0)[/tex]
[tex]P_{10} =0.1 +0[/tex]
[tex]P_{10} =0.1[/tex]
Sum.Write a program that prompts the user to read two integers and displays their sum.Your program should prompt the user to read the number again if the input is incorrect.
Answer:
while True:
number1 = input("Enter the number1: ")
number2 = input("Enter the number2: ")
if number1.isnumeric() and number2.isnumeric():
break
number1 = int(number1)
number2 = int(number2)
print("The sum is: " + str(number1 + number2))
Explanation:
*The code is in Python.
Create an infinite while loop. Inside the loop, Get the number1 and number2 from the user. Check if they are both numeric values. If they are, stop the loop (Otherwise, the program keeps asking for the numbers).
When the loop is done, convert the numbers to integer numbers
Calculate and print their sum
Some systems analysts maintain that source documents are unnecessary. They say that an input can be entered directly into the system, without wasting time in an intermediate step.
Do you agree? Can you think of any situations where source documents are essential?
Answer:
The summary including its given subject is mentioned in the portion here below explanatory.
Explanation:
No, I disagree with the argument made by 'system analyst' whether it is needless to preserve source records, rather, therefore, the details provided input would be fed immediately into the machine. Different source document possibilities can be considered may play a significant role in accessing data.Assumed a person experiences a problem when collecting and analyzing data that has no complete access or that individual is not happy with the system or that may want comprehensive data search. However, a need arises to keep data both sequentially and fed further into the desktop system that would help us through tracking purposes.Even with all the documentation that has been held is essentially for the user to do anything efficiently and conveniently without even any issues and 'device analyst' would guarantee that it has been applied in a very well-defined way.Assign max_sum with the greater of num_a and num_b, PLUS the greater of num_y and num_z. Use just one statement. Hint: Call find_max() twice in an expression.
Sample output with inputs: 5.0 10.0 3.0 7.0
max_sum is: 17.0
1 det find_max(num_1, num_2):
2 max_val = 0.0
3
4 if (num_1 > num_2): # if num1 is greater than num2,
5 max_val = num_1 # then num1 is the maxVal.
6 else: # Otherwise,
7 max_val = num_2 # num2 is the maxVal
8 return max_val
9
10 max_sum = 0.0
11
12 num_a = float(input)
13 num_b = float(input)
14 num_y = float(input)
15 num_z = float(input)
16
17"" Your solution goes here
18
19 print('max_sum is:', max_sum)
Answer:
def find_max(num_1, num_2):
max_val = 0.0
if (num_1 > num_2): # if num1 is greater than num2,
max_val = num_1 # then num1 is the maxVal.
else: # Otherwise,
max_val = num_2 # num2 is the maxVal
return max_val
max_sum = 0.0
num_a = float(input())
num_b = float(input())
num_y = float(input())
num_z = float(input())
max_sum = find_max(num_a, num_b) + find_max(num_y, num_z)
print('max_sum is:', max_sum)
Explanation:
I added the missing part. Also, you forgot the put parentheses. I highlighted all.
To find the max_sum, you need to call the find_max twice and sum the result of these. In the first call, use the parameters num_a and num_b (This will give you greater among them). In the second call, use the parameters num_y and num_z (This will again give you greater among them)
Write a program that asks for the weight of a package and the distance it is to be shipped. This information should be passed to a calculateCharge function that computes and returns the shipping charge to be displayed . The main function should loop to handle multiple packages until a weight of 0 is entered.
Answer:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int WEIGHT_MIN = 0,
WEIGHT_MAX = 20,
DISTANCE_MIN = 10,
DISTANCE_MAX = 3000;
float package_weight,
distance,
total_charges;
cout << "\nWhat is the weight (kg) of the package? ";
cin >> package_weight;
if (package_weight <= WEIGHT_MIN ||
package_weight > WEIGHT_MAX)
{
cout << "\nWe're sorry, package weight must be\n"
<< " more than 0kg and less than 20kg.\n"
<< "Rerun the program and try again.\n"
<< endl;
}
else
{
cout << "\nDistance? ";
cin >> distance;
if (distance < DISTANCE_MIN ||
distance > DISTANCE_MAX)
{
cout << "\nWe're sorry, the distance must be\n" << "within 10 and 3000 miles.\n"
<< "Rerun the program and try again.\n"
<< endl;
}
else
{
if (package_weight <= 2)
total_charges = (distance / 500) * 1.10;
else if (package_weight > 2 &&
package_weight <= 6)
total_charges = (distance / 500) * 2.20;
else if (package_weight > 6 &&
package_weight <= 10)
total_charges = (distance / 500) * 3.70;
else if (package_weight > 10 &&
package_weight <= 20)
total_charges = (distance / 500) * 4.80;
cout << setprecision(2) << fixed
<< "Total charges are $"
<< total_charges
<< "\nFor a distance of "
<< distance
<< " miles\nand a total weight of "
<< package_weight
<< "kg.\n"
<< endl;
}
}
Explanation:
Consider a system consisting of m resources of the same type, being shared by n processes. Resources can be requested and released by processes only one at a time. Show that the system is deadlock free if the following two conditions hold:__________.
A. The maximum need of each process is between 1 and m resources
B. The sum of all maximum needs is less than m+n.
Answer:
Explanation:
The system will be deadlock free if the below two conditions holds :
Proof below:
Suppose N = Summation of all Need(i), A = Addition of all Allocation(i), M = Addition of all Max(i). Use contradiction to prove.
Suppose this system isn't deadlock free. If a deadlock state exists, then A = m due to the fact that there's only one kind of resource and resources can be requested and released only one at a time.
Condition B, N + A equals M < m + n. Equals N + m < m + n. And we get N < n. It means that at least one process i that Need(i) = 0.
Condition A, Pi can let out at least 1 resource. So there will be n-1 processes sharing m resources now, Condition a and b still hold. In respect to the argument, No process will wait forever or permanently, so there's no deadlock.
Explain ways that computer-related errors are associated with the people using those computers. Contrast that with errors made by the computer systems directly.
Answer and Explanation:
Computer related errors associated with people that use these computers are errors that are made by human beings in instructing(or programming) the computer to do or complete a certain task. This could involve such things as moving paper based data to the computer(electronic data) where the human could enter incorrect data or inconsistent programs or code.
Computer related errors which directly have to do with the computer consist of error thrown by the system as a result of ineffective code or software related issues or faulty hardware. In either case all computer related errors are inherently caused by humans since a computer would only take instruction given to it.
5.19 LAB: Countdown until matching digits Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is:
Answer:
Following are the code to this question:
x = int(input())#defining a variable x for user input value
if(x>=20 and x<=98):#defining an if block that checks value is in between 20 to 98
while(not(x%10==x//10)):#defining while loop that seprate numbers and checks it is not equal
print(x)#print value
x-=1# decrease value by subtracting 1
print(x)# print value
else:#defining else block
print("The input value must lie in 20-98")#print message
Output:
36
36
35
34
33
Explanation:
In the above python program code, a variable x is declared, which is used to input the value from the user end. In the next step, a conditional statement is used in if block, it checks the input value is lie in 20 to 98, and to check its uses and logic date, if it is false it will goto else section in this, it will print a message. If the given value is true, inside if block a while loop is declared, that separately divide the value and check it is identical or not, if it is not identical it will print the value and checks its less value similarly.The program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical is as follows:
x = int(input("your number should be between 20 to 98: "))
while 20 <= x <= 98:
print(x, end='\n')
if x % 11 == 0:
break
x -= 1
else:
print("your number must be between 20 to 98")
Code explanation:The code is written in python
The first line of code, we store the users input in the variable x.Then while 20 is less than or equal to or less than and equals to the users input, we have to print the x value .If the users input divides 11 without remainder(the digit are the same) then we break the loop. The loop continue as we subtract one from the users valueThe else statement wants us to tell the user to input numbers between 20 to 98learn more on python code here: https://brainly.com/question/26104476
in an agile team who is responsible for tracking the tasks
Answer:
All team members
Explanation:
In respect of the question, the or those responsible for tracking the tasks in an agile team comprises of all the team members.
Agile in relation to task or project management, can be refer to an act of of division of project or breaking down of project or tasks into smaller unit. In my opinion, these is carried out so that all team members can be duly involved in the tasks or project.
How many times does the following loop execute? double d; Random generator = new Random(); double x = generator.nextDouble() * 100; do { d = Math.sqrt(x) * Math.sqrt(x) - x; System.out.println(d); x = generator.nextDouble() * 10001; } while (d != 0); exactly once exactly twice can't be determined always infinite loop
Answer:
The number of execution can't always be determines
Explanation:
The following points should be noted
Variable d relies on variable x (both of double data type) for its value
d is calculated as
[tex]d = \sqrt{x}^2 - x[/tex]
Mere looking at the above expression, the value of d should be 0;
However, it doesn't work that way.
The variable x can assume two categories of values
Small Floating Point ValuesLarge Floating Point ValuesThe range of the above values depend on the system running the application;
When variable x assumes a small value,
[tex]d = \sqrt{x}^2 - x[/tex] will definitely result in 0 and the loop will terminate immediately because [tex]\sqrt{x}^2 = x[/tex]
When variable x assumes a large value,
[tex]d = \sqrt{x}^2 - x[/tex] will not result in 0 because their will be [tex]\sqrt{x}^2 \neq x[/tex]
The reason for this that, the compiler will approximate the value of [tex]\sqrt{x}^2[/tex] and this approximation will not be equal to [tex]x[/tex]
Hence, the loop will be executed again.
Since, the range of values variable x can assume can not be predetermined, then we can conclude that the number of times the loop will be executed can't be determined.