Explanation:
Remember, an algorithm in simple words means a set of instructions or steps to be followed in other to solve a problem.
Note, to decide which commute is cheaper, it means the output of the algorithm should be the cheaper way to commute.
Using pseudocode do the following;
determine the inputs and outputs of the problem arrange the identified problem into micro-tasksdescribe each micro-tasks in the pseudocode Test the pseudocode by solving the problem.
Consider three different processors P1, P2, and P3 executing the same instruction set. P1 has a 3GHz clock rate and a CPI of 1.5. P2 has a 2.5GHz clock rate and a CPI of 1.0. P3 has a 4.0GHz clock rate and has a CPI of 2.2. a. Which processor has the highest performance expressed in instructions per second? b. If the processors each execute a program in 10 seconds, find the number of cycles and the number of instructions. c. We are trying to reduce the execution time by 30%, but this leads to an increase of 20% in the CPI. What clock rate should we have to get this time reduction?
Answer:
See explanation
Explanation:
Given:
Processors:
P1
P2
P3
Clock Rate of Processors:
Clock rate of P1 = 3 GHz
Clock rate of P2 = 2.5 GHz
Clock rate of P3 = 4.0 GHz
CPI of Processors:
Cycles per instruction = CPI of P1 = 1.5
Cycles per instruction = CPI of P2 = 1.0
Cycles per instruction = CPI of P3 = 2.2
To find:
a) Which processor has the highest performance expressed in instructions per second
Solution:
Performance = clock rate / CPI
The performance of processor depends on instructions count and CPU time.
As we know that
CPU time = Instructions * Cycles Per Instruction / clock rate
CPU time = Instructions * CPI / clock rate
Instructions per second = Instruction count / CPU time
As:
CPU time = Instructions * CPI/ clock rate
Instructions/CPU time = clock rate/CPI
Instructions per second = clock rate / CPI
IPS = clock rate/ CPI
Hence
Performance = Clock rate / CPI = clock rate/ CPI
Compute Performance of P1:
Performance for P1 = IPS of P1 = clock rate of P1 / CPI of P1 = 3 GHz / 1.5 = 2
As we know that 1 GHz = 10⁹ Hz. So:
Performance of P1 expressed in instructions per second is 2 x 10⁹
Compute Performance of P2:
Performance for P2 = IPS of P2= clock rate of P2 / CPI of P2 = 2.5 GHz / 1.0 = 2 .5
As we know that 1 GHz = 10⁹ Hz. So:
Performance of P1 expressed in instructions per second is 2.5 x 10⁹
Compute Performance of P3:
Performance for P3 = IPS of P3= clock rate of P3 / CPI of P3 = 4.0 GHz / 2.2 = 1.82
As we know that 1 GHz = 10⁹ Hz. So:
Performance of P1 expressed in instructions per second is 1.82 x 10⁹
From the above computed performances of each processor it can be seen that Processor 2 (P2) has the highest performance expressed in instructions per second i.e. 2.5 x 10⁹
b) find the number of cycles and the number of instructions.
Given:
processors each execute a program in 10 seconds, So,
CPU time = 10 sec
Solution:
Compute number of cycles:
As we know that:
CPU time = cycles count / clock rate = clock cycles/clock rate
So
clock cycles = CPU time x clock rate
Compute number of cycles of P1:
clock cycles = 10 x 3 GHz
= 30
As we know that 1 GHz = 10⁹ Hz. So:
clock cycles of P1 = 3 x 10¹⁰
Compute number of cycles of P2:
clock cycles = 10 x 2.5 GHz
= 25
As we know that 1 GHz = 10⁹ Hz. So:
clock cycles of P2 = 2.5 x 10¹⁰
Compute number of cycles of P3:
clock cycles = 10 x 4.0 GHz
= 40
As we know that 1 GHz = 10⁹ Hz. So:
clock cycles of P3 = 4 x 10¹⁰
Now as we know that:
Instructions per second = Instruction count / CPU time
IPS = IC + CPU time
So to find number of instructions:
instruction count = Instructions per second x CPU time
Compute number of instructions of P1:
instructions of P1 = Instructions per second of P1 x CPU time
= 2 x 10⁹ x 10
= 2 x 10¹⁰
Compute number of instructions of P2:
instructions of P2 = Instructions per second of P2 x CPU time
= 2.5 x 10⁹ x 10
= 2.5 x 10¹⁰
Compute number of instructions of P3:
instructions of P3 = Instructions per second of P3 x CPU time
= 1.82 x 10⁹ x 10
= 1.82 x 10¹⁰
c) What clock rate should we have to reduce the execution time by 30%
As we know
CPU time = Execution time = instructions x CPI / clock rate
We have to find new clock rate to reduce execution time by 30%
This means we have to find:
New Execution Time = 70% of Old Execution Time
According to formula of Execution time:
instructions(new) x CPI(new) / clock rate(new) = 0.7 [instructions(old) x CPI(old) / clock rate(old)]
As the instructions(new) = instructions(old)
So,
CPI(new) / clock rate(new) = 0.7 [CPI(old) / clock rate(old)]
When trying to reduce the execution time by 30%, this leads to an increase of 20% in the CPI.
CPI(new) = 1.2 CPI(old)
New CPI of P1:
CPI(new P1) = 1.2 CPI(old P1)
= 1.2 x 1.5
CPI(new P1) = 1.8
New CPI of P2:
CPI(new P2) = 1.2 CPI(old P2)
= 1.2 x 1.0
CPI(new P2) = 1.2
New CPI of P3:
CPI(new P3) = 1.2 CPI(old P3)
= 1.2 x 2.2
CPI(new P3) = 2.6
1.2 / clock rate (new) = 0.7 / clock rate(old)
So new clock rate is computed as:
clock rate (new) = (1.2 / 0.7 ) x clock rate(old)
clock rate (new) = 1.71 x clock rate(old)
clock rate (new) = 1.71 x clock rate(old)
Hence the clock rate should be increased by 71% approx.
Now new clock rate for each processor is:
clock rate (new) for P1 = 3 GHz x 1.71 = 5.13 GHz
clock rate (new) for P2 = 2.5 GHz x 1.71 = 4.27 GHz
clock rate (new) for P3 = 4.0 GHz x 1.71 = 6.84 GHz
In this exercise we have to use CPU and processor knowledge, so we can say that:
A)Processador 2
B) Processador 3
C) Processador 3
From the information given in the text we have:
Clock rate of P1 = 3 GHz Clock rate of P2 = 2.5 GHz Clock rate of P3 = 4.0 GHz CPI of P1 = 1.5 CPI of P2 = 1.0 CPI of P3 = 2.2
a) With the formula bellow, we find:
[tex]Performance = clock \ rate / CPI[/tex]
The performance of processor depends on instructions count and CPU time.
Compute Performance of P1:
[tex]P= 3 GHz / 1.5 = 2*10^9[/tex]
Compute Performance of P2:
[tex]P = 2.5 GHz / 1.0 = 2 .5*10^9[/tex]
Compute Performance of P3:
[tex]P = 4.0 GHz / 2.2 = 1.82 *10^9[/tex]
b) Processors each execute a program in 10 seconds, So:
P1:
[tex]10 * 3 GHz = 30*10^{10}[/tex]
P2:
[tex]10 * 2.5 GHz= 25*10^{10[/tex]
P3:
[tex]10 * 4.0 GHz = 40*10^{10[/tex]
c) So for reduce we have:
New CPI of P1:[tex]CPI = 1.2 CPI = 1.2 * 1.5CPI = 1.8[/tex]
New CPI of P2:
[tex]CPI= 1.2 CPI = 1.2 * 1.0\\CPI= 1.2[/tex]
New CPI of P3:
[tex]CPI= 1.2 CPI = 1.2 *2.2\\CPI = 2.6[/tex]
Now new clock rate for each processor is:
[tex]clock rate (new) for P1 = 3 GHz x 1.71 = 5.13 GHz\\clock rate (new) for P2 = 2.5 GHz x 1.71 = 4.27 GHz\\clock rate (new) for P3 = 4.0 GHz x 1.71 = 6.84 GHz[/tex]
See more about processor at brainly.com/question/8015023
what is the function of control unit? in computer.
regulates and integrates the operations of the computer. It selects and retrieves instructions from the main memory in proper sequence and interprets them
What is the range of possible values for the variable x?
int x = (int)(Math.random() * 10);
Answer:
int number = (int)(Math. random() * 10); By multiplying the value by 10, the range of possible values becomes 0.0 <= number < 10.0
please mark me as the brainliest answer and please follow me for more answers.
_____ is the operation of setting a variable to a value.
Answer:
Assignment is the operation of a variable to a value
Horizontal scaling of a client/server architecture means _____.
a. migrating the network to decentralized servers.
b. migrating the network to a faster communication media.
c. adding more proxy servers.
d. adding more workstations.
Answer:
D. I think
Explanation:
Horizontal scaling of a client/server architecture means adding more workstations. Thus the correct option is D.
What is client/server architecture?A computing model which places the majority of the services and features that the client requests on the server, which also hosts, delivers, and manages them are known as client-server architecture
Most applications that call for a division of labor between the client and the server benefit from the client-server architecture. The accessibility performance of applications is improved.
Both horizontal and vertical scaling is possible for client/server architectures. If a network is scaled vertically, more powerful, faster servers are added to the network, whereas horizontal scaling involves adding additional workstations (clients).
Therefore, option D is appropriate.
Learn more about client/server architecture, here:
https://brainly.com/question/21755186
#SPJ5
A(n) _____ website gathers, organizes, and then distributes web content.
Answer:
content aggregator
Explanation:
:)
Which WPA mode allows users to provide authentication via a pre-shared key or password?
Answer:
WPA2 allows users to provide authentication via a pre-shared network key / password
Explanation:
The WPA mode that allows users to provide authentication via a pre-shared key or password is the personal mode. The correct option is a.
What is WPA mode?The most recent and secure Wi-Fi protocol at the moment is WPA3 Personal. A pre-shared key is used by Personal WPA to verify users' first login information.
Wi-Fi security access All users on 2 pre-shared key (WPA-PSK) networks use the same passphrase. A security standard for computing devices using wireless internet connections is called Wi-Fi Protected Access (WPA).
It was created by the Wi-Fi Alliance to provide stronger user authentication and data encryption than the original Wi-Fi security standard, Wired Equivalent Privacy (WEP).
Therefore, the correct option is a. Personal mode.
To learn more about WPA mode, refer to the link:
https://brainly.com/question/29034850
#SPJ5
The question is incomplete. Your most probably complete question is given below:
a. Personal mode
b. Enterprise mode
c. Extensible Authentication Protocol mode
d. Wired Equivalent Privacy mode
How many different values can be stored in a byte?
Answer:
255
Explanation:
1 byte has 8 bits, that is, 8 combinations of binary inputs, which can result in calculations up to the number 2 ^ 8-1 = 255 (-1 because 0 will always be the first number), a computer nowadays has 64 bits (8bytes ), thus being able to calculate numbers up to 2 ^ 64-1, an integer file has 4 bytes, being able to calculate up to 2 ^ 32-1, and so on.
Name three actions you should take if you believe you’ve been victimized by crimeware or online fraud
Try restating system software and delete anything that may have caused the online fraud then remove all credit cards and info on the device. Tell the authorities and get a new device and email with a software protector. When doing this DO NOT DO WHAT YOU ORIGINALLY DID TO GET VICTIMIZED AND (DON'T TRY TO SIGN INTO YOUR PREVIOUS EMAIL ON A NEW DEVICE)
Write code to assign the number of characters in the string rv to a variable num_chars.
Answer:
rv = "hello"
num_chars = len(rv)
print(num_chars)
Explanation:
*The code is in Python.
Initialize the string rv, in this example I set it to "hello"
Use the len() method to get the number of characters in the rv and set it to the num_chars
Print the num_chars
Note that the result will be 5 in this case, because hello consists of five characters
A WHILE loop can be constructed with a CMP instruction at the bottom of the loop, followed by a conditional jump instruction.
a) true
b) false
Answer:
false
Explanation:
If the condition is false at the start, the contents of the loop should never be executed. If the CMP is at the end, you cannot prevent the code to run at least once. So this approach will work for a DO { ... } WHILE() loop, but not for a regular WHILE() { ... }
Create a cell reference in a format by typing in the cell name or
Answer:
D. Create a cell reference in a formula by typing in the cell name or clicking the cell.
Further Explanation:
To create a cell reference in a formula the following procedure is used:
First, click on the cell where you want to add formula.
After that, in the formula bar assign the equal (=) sign.
Now, you have two options to reference one or more cells. Select a cell or range of cells that you want to reference. You can color code the cell references and borders to make it easier to work with it. Here, you can expand the cell selection or corner of the border.
Again, now define the name by typing in the cell and press F3 key to select the paste name box.
Finally, create a reference in any formula by pressing Ctrl+Shift+Enter.
Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x miles per hour and car B travels south at an average speed of y miles per hour. Write a program that prompts the user to enter: The average speed of both the cars The elapsed time (in hours and minutes, separated by a space) Ex: For two hours and 30 minutes, 2 30 would be entered
Answer:
Here is the C++ program:
#include <iostream> // to use input output functions
#include <cmath> // to use math functions like sqrt()
#include <iomanip> //to use setprecision method
using namespace std; //to access objects like cin cout
int main () { //start of main function
double speedA; //double type variable to store average speed of car A
double speedB; //double type variable to store average speed of car B
int hour; //int type variable to hold hour part of elapsed time
int minutes; //int type variable to hold minutes part of elapsed time
double shortDistance; // double type variable to store the result of shortest distance between car A and B
double distanceA; //stores the distance of carA
double distanceB; //stores the distance of carB
double mins,hours; //used to convert the elapsed time
cout << "Enter average speed of car A: " << endl; //prompt user to enter the average speed of car A
cin >> speedA; //reads the input value of average speed of car A from user
cout << "Enter average speed of car B: " << endl ; //prompt user to enter the average speed of car B
cin >> speedB; //reads the input value of average speed of car A from user
cout << "Enter elapsed time (in hours and minutes, separated by a space): " << endl; //prompts user to enter elapsed time
cin>> hour >> minutes; //reads elapsed time in hours and minutes
mins = hour * 60; //computes the minutes using value of hour
hours = (minutes+mins)/60; //computes hours using minutes and mins
distanceA = speedA * (hours); // computes distance of car A
distanceB = speedB * (hours); //computes distance of car B
shortDistance =sqrt((distanceA * distanceA) + (distanceB * distanceB)); //computes shortest distance using formula √[(distanceA)² + (distanceB)²)]
cout << "The (shortest) distance between the cars is: "<<fixed<<setprecision(2)<<shortDistance;
//display the resultant value of shortDistance up to 2 decimal places
Explanation:
I will explain the program with an examples:
Let us suppose that the average speeds of cars are:
speedA = 70
speedB = 55
Elapsed time in hours and minutes:
hour = 2
minutes = 30
After taking these input values the program control moves to the statement:
mins = hour * 60;
This becomes
mins = 2 * 60
mins = 120
Next
hours = (minutes+mins)/60;
hours = (30 + 120) / 60
= 150/60
hours = 2.5
Now the next two statements compute distance of the cars:
distanceA = speedA * (hours);
this becomes
distanceA = 70 * (2.5)
distanceA = 175
distanceB = speedB * (hours);
distanceB = 55 * (2.5)
distanceB = 137.5
Next the shortest distance between car A and car B is computed:
shortDistance = sqrt((distanceA * distanceA) + (distanceB * distanceB));
shortDistance = sqrt((175 * 175) + (137.5 * 137.5))
= sqrt(30625 + 18906.25)
= sqrt(49531.25)
= 222.556173
shortDistance = 222.56
Hence the output is:
The (shortest) distance between the cars is: 222.56
When visiting a museum Lian takes a photo of a painting with a smartphone which stores the photo as an image file. Which of the following best describes the differences between the painting itself and the photo of the painting stored on the smartphone? A. Both the painting and the photo are analog B. The photo is a digital representation of the analog painting C. Sampling can be used to determine whether the analog image is an accurate representation of the painting D. The phone can represent the photo in either digital or analog formats depending on the sampling technique that is used
The best statement that best describes the differences between the painting itself and the photo of the painting stored on the smartphone is that the photo is a digital representation of the analog painting.
For better Understanding, we have to know about analog and digital terms means
Analog simply means a way of giving out information by a regular but different signal. Digital simply means a way of storing or giving out information by discrete, non regular ways.The painting is the analog while the photo is the digital copy. the photo is a copy of the original and when you look at it, the photo is not giving continous signals like an analog.From the above, we can therefore say that the answer that the photo is a digital representation of the analog painting is true.
learn more about digital and analog from:
https://brainly.com/question/1388235
After analyzing the following code, which statement is not True:
import sqlite3
connection = sqlite3.connect("aquarium.db")
a. import sqlite3 gives our Python program access to the sqlite3 module.
b. The sqlite3.connect() function returns a Connection object
c. The aquarium.db file is created automatically by sqlite3.connect() if aquarium.db does not already exist on our computer.
d. A syntax error, if aquarium.db does not already exist on our computer.
Answer:
d. A syntax error, if aquarium.db does not already exist on our computer.
Explanation:
The SQLite database is a relational database used readily in python backend web frameworks to store and retrieve data. The python packages like the sqlite3 are extensions of python proving its flexibility and power as a multi-purpose programming language.
The sqlite3 package is first installed and imported in the python file and a sqlite connection is made to the database which is automatically saved in the aquarium.db file ( created if it doesn't already exist ).
Write a program that converts a time in 12-hour format to 24-hour format. The program will prompt the user to enter a time in HH:MM:SS AM/PM form. (The time must be entered exactly in this format all on one line.) It will then convert the time to 24 hour form. You may use a string type to read in the entire time at once, including the space before AM/PM, or you may choose to use separate variables for the hours, minutes, seconds and AM/PM.
Answer:
This program is written in Python
inputtime = input("HH:MM:SS AM/PM: ")
splittime = inputtime.split(":")
secondAM = splittime[2].split()
if secondAM[1] == "AM":
print(splittime[0]+":"+splittime[1]+":"+secondAM[0])
elif secondAM[1] == "PM":
HH = int(splittime[0])
HH = HH + 12
print(str(HH)+":"+splittime[1]+":"+secondAM[0])
Explanation:
This line prompts user for input
inputtime = input("HH:MM:SS AM/PM: ")
This line splits the input string to HH, MM and "SS AM/PM"
splittime = inputtime.split(":")
This line splits "SS AM/PM" to SS and AM/PM
secondAM = splittime[2].split()
This line checks if time is AM
if secondAM[1] == "AM":
This line prints the equivalent time
print(splittime[0]+":"+splittime[1]+":"+secondAM[0])
Else;
elif secondAM[1] == "PM":
The equivalent 24 hour is calculated
HH = int(splittime[0]) + 12
This line prints the equivalent time
print(str(HH)+":"+splittime[1]+":"+secondAM[0])
Write a script which: Uses the input function to get any number and store it in a variable named my_number Create a new variable named calculation which equals my_number plus 9 Multiply calculation by 2 Subtract 4 from calculation Divide calculation by 2 Subtract my_number from calculation Print calculation
# Using the input function
# Prompt the user to input some number
# Convert the input to a float - this will cater for both floating
# numbers and integers
# Store the result in a variable called my_number
my_number = float(input('Please enter some number '))
#Create a variable named calculation which equals my_number plus 9
calculation = my_number + 9
#Multiply calculation by 2
calculation *= 2
#Subtract 4 from calculation
calculation -= 4
#Divide calculation by 2
calculation /= 2
#Subtract my_number from calculation
calculation -= my_number
#Print calculation
print('calculation = ' + str(calculation))
Sample Output>> Please enter some number 8
calculation = 7.0
Explanation:The above program has been written in Python and it contains comments explaining each line of the code. Please go through the comments. A sample output has also been provided.
What is hardware?
O All elements of a computer
O The parts of a computer that you can touch
O Wooden planks sold in a hardware store
The parts of software that you can't see
Where does the CPU store its computations?
A. Registers
B. External Data Bus
C. Binary
D. Processor
Answer: A. Registers
Explanation:
Option A is correct. The CPU stores its computations in the Registers
The CPU is known as the Central Processing Unit.
The CPU is useful in reading data and instructions from memory and then stores the results of what was computed in its main memory.This computation in the main memory is usually stored in the Register.Hence we can conclude that the CPU store its computations in the Register.
Learn more here: https://brainly.com/question/18259388
Write a Java program to count the characters in each word in a given sentence?Examples:Input : geeks for geeksOutput :geeks->5for->3geeks->5
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a sentence: ");
String sentence = in.nextLine();
String[] words = sentence.split("\\s");
for(String s : words)
System.out.println(s + " -> " + s.length());
}
}
Explanation:
Ask the user to enter a sentence
Get each word in the sentence using split method and put them in words array
Loop through the words. Print each word and number of characters they have using the length method in required format
Read the following program requirements prior to completing the Hands-on. A retail company must file a monthly sales tax report listing the total sales for the month and the amount of state and county sales tax collected. The state sales tax rate is 4 percent and the county sales tax rate is 2 percent. Write a program that asks the user to enter the total sales for the month. The application should calculate and display the following: • The amount of county sales tax • The amount of state sales tax • The total sales tax (county plus state) Step 1: Write the steps the algorithm:
Answer:
state_sales_tax_rate = 0.04
county_sales_tax_rate = 0.02
sales = float(input("Enter the total sales for the month: "))
county_sales_tax = sales * county_sales_tax_rate
state_sales_tax = sales * state_sales_tax_rate
total_sales_tax = county_sales_tax + state_sales_tax
print("The amount of county sales tax is " + str(county_sales_tax))
print("The amount of state sales tax is " + str(state_sales_tax))
print("The total sales tax is " + str(total_sales_tax))
Explanation:
*The code is in Python.
Set the state_sales_tax_rate and county_sales_tax_rate
Ask the user to enter the sales
Calculate the county_sales_tax, multiply sales by county_sales_tax_rate
Calculate the state_sales_tax, multiply sales by state_sales_tax_rate
Calculate the total_sales_tax, sum county_sales_tax and state_sales_tax
Print the results
Consider the definition in OCaml
let fabcd = a.(if b then c else d)
Which of the following must hold (zero, one or more answers can be correct)?
A. The type of a is int array.
B. The type of b is bool.
C. The type of c is int.
D. The type of d is int.
E. The return type of f is int.
Answer:
The type of b is bool ( B )
The type of c is int ( C )
The type of d is int ( D )
Explanation:
The options that must hold zero are: The type of b is bool,The type of d is int and The type of c is int.
If b is true then c or d is true because c and d are int. this is because b been a true/false means that d and c are boolean int. because d and c are assigned to integers
The statements that must hold are:
b. The type of b is bool c. The type of c is int d. The type of d is int
The definition is given as:
let fabcd = a.(if b then c else d)
From the above definition, we have the following if condition
if b then c else d
This means that:
Variable b can only take either true or false, as its value.
So, b is of Boolean type
Variables c and d can take any numerical data type such as int, floats, and any character type such as char and string.
This means that:
Options (c) and (d) can also hold.
Hence, the true options are: (b), (c) and (d)
Read more about program definition at:
https://brainly.com/question/25665378
Write a MATLAB function named lin_spaced_vector with two inputs and one return value. The first input will be a single real number representing a lower bound The second input will be a single real number representing an upper bound The return value must be a list of 200 numbers evenly spaced between the lower bound and the upper bound.
Explanation:
==================
lin_spaced_vector.m
==================
function out=lin_spaced_vector(in1,in2)%defining function
out=linspace(in1,in2,200);%200 spaced numbers between in1 and in2
end
===================
Executable File
===================
clear all%clears history
clc%clears screen
lin_spaced_vector(1,10)%calling function
clear all
clc
lin_spaced_vector(1,10)
Consider the following algorithm: ```c++ Algorithm Mystery(n) { // Input:A nonnegative integer n S = 0; for i = 1 to n do { S = S + i * i; } return S } ``` 1. What does this algorithm compute? 2. What is its basic operation? 3. How many times is the basic operation executed? 4. What is the efficiency class of this algorithm? 5. Suggest an improvement, or a better algorithm altogether, and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done.
Answer:
See explanation
Explanation:
First let us find what this algorithm compute:
Algorithm Mystery(n) {
S = 0;
for i = 1 to n do
{ S = S + i * i; }
return S }
1)
Let suppose n = 3
S = 0
The algorithm has a for loop that has a loop variable i initialized to 1
At first iteration:
i = 1
S = S + i * i;
= 0 + 1 * 1
S = 1
At second iteration:
i = 2
S = 1
S = S + 2 * 2;
= 1 + 2 * 2
= 1 + 4
S = 5
At third iteration:
i = 3
S = 5
S = S + 3 * 3;
= 5 + 3 * 3
= 5 + 9
S = 14
Now the loop breaks at i=4 because loop iterates up to n and n =3
So from above example it is clear that the algorithm computes the sum of squares of numbers from 1 to n. Or you can say it compute the sum of first n squares. Let us represent this statement in mathematical form:
∑[tex]\left \ {{n} \atop {i=1}} \right.[/tex] i²
2)
From above example we can see that the basic operation is multiplication. At every iteration loop variable i is multiplied by itself from 1 to n or till n times. However we can also say that addition is the basic operation because at each iteration the value of S is added to the square of i. So it takes the same amount of time.
3)
In the for loop, the basic operation executes once. We can say that at each iteration of the loop, multiplication is performed once. Suppose A(n) represents the number of times basic operation executes then,
A(n) = ∑[tex]\left \ {{n} \atop {i=1}} \right.[/tex] 1 = n
4)
Since for loop executes once for each of the numbers from 1 to n, so this shows that for loop executes for n times. The basic operation in best, worst or average case runs n times. Hence the running time of Θ(n) . We can say that A(n) = n ∈ Θ(n)
If b is the number of bits needed to represent n then
b = log₂n + 1
b = log₂n
So
n ≈ [tex]2^{b}[/tex]
A(n) ≈ [tex]2^{b}[/tex] ≈ Θ( [tex]2^{b}[/tex] )
5)
One solution is to calculate sum of squares without using Θ(n) algorithm. So the efficient algorithm that takes less time than the previous algorithm is:
Algorithm Mystery(n) {
S = 0;
S = (n * ( n + 1 ) (2n + 1) ) / 6 ;
return S}
Now the sum can be calculated in Θ(1) times. This is because regardless of the size and number of operands/operations, the time of arithmetic operation stays the same. Now lets find out how this algorithm works for
n = 3
S = (n * ( n + 1 ) (2n + 1) ) / 6 ;
= (3 * ( 3 + 1 ) * (2(3) + 1) ) / 6
= (3 * (4) * (6+1)) / 6
= (3 * (4) * (7)) / 6
= (3 * 4 * 7) / 6
= 84 / 6
S = 14
Are scripted languages easier or more difficult to port than programming languages? Why?
Answer:
Scripting languages are easier to port to various platforms due to the compiling and interpreting tools it uses to read the source code.
Explanation:
Programming languages are used to create source codes for various applications from web programming to mobile application implementation.
A programming language can be a scripting language, only with the required tools like a compiler or an interpreter. For example, C source codes are compiled to executable scripting file with the GCC compiler and python codes are interpreted with the cpython interpreter.
Scenario2: Now suppose the LAN must support both voice and data and you must choose one of these multiple access strategies in order to support both applications on the same network, with the understanding that voice calls are more important than data. Which would you choose and why? How would voice and data be sent in this scenario? That is, which access protocol would you use, or adapt/modify, and why?
Answer:
The RTP (real time protocol) which uses the UDP ( user datagram protocol) and Real-time control protocol.
Explanation:
The RTP of a voice over IP protocol (VoIP) which is used to prioritise the transfer of video and audio data over text data. It is used for video conferencing and telephony services in an enterprise.
It uses the user-datagram protocol to transfer or access videos and audio data for its real time effect and the real-time control protocol for quality of service analysis and maintenance.
Which does a traditional camera need in order to capture images?
A. secure digital (SD) card B. printer C. scanner D. film
Answer:
I think secure digital is needed
Answer:
Film
Explanation:
I chose Film and got it correct
Describe what each of the following functions in R do.1. t2. matplot3. c4. seq5. legend6. matrix7. rownames8. colnames9. type of
Answer:
1. t is a function used to transpose a matrix object. The object is passed as an argument to the function.
2. matplot is a graphical function in R used for data visualization.
3. The c function is used to combine arguments.
4. seq is an R function used to derive a range of numbers, optionally specifying a start, stop and step argument or simply a single numeric argument.
5. legends are used in data visualization to list and define items in the graphical presentation.
6. matrix is a function in R used to create and work with matrix and data frame objects.
7. rownames and colnames are functions used to label the row and columns of a data frame in R.
8. The typeof function return the data type of an object.
Explanation:
The R programming language is a dedicated programming language for data analysis and visualization.
Explain the basic method for implementing paging.
Answer:
The answer is below
Explanation:
In order to carry out the basic method for implementing paging, the following processes are involved:
1. Both physical and logical memories are broken into predetermined sizes of blocks otherwise known as FRAMES and PAGES respectively
2. During processing, Pages are loaded into the accessible free memory frames from the backing store. The backing store is however compartmentalized into predetermined sizes of blocks whose size is equal to the size of the memory frames
2. Which of the following is a
Web 2.0 programming
methodology you could use to
create Web pages that are
dynamic and interactive without
the need to refresh or
reload the page?
a. Wiki
b. RSS
c. Blog
d. Ajax
Answer:ajax
Explanation: