Answer:
Here are the programs. I am writing C++ and Python programs:
a)
C++
#include<iostream>
using namespace std;
int factorial(int number) {
if (number == 0)
return 1;
return number * factorial(number - 1); }
int main() {
int integer;
cout<<"Enter a non negative integer: ";
cin>>integer;
cout<< "Factorial of "<< integer<<" is "<< factorial(integer)<< endl; }
Python:
def factorial(number):
if number == 0:
return 1
return number * factorial(number-1)
integer = int(input("Enter a non negative integer: "))
print("Factorial of", integer, "is", factorial(integer))
b)
C++
#include <iostream>
using namespace std;
double factorial(int number) {
if (number == 0)
return 1;
return number * factorial(number - 1); }
double estimate_e(int num){
double e = 1;
for(int i = 1; i < num; i++)
e = e + 1/factorial(i);
cout<<"e: "<< e; }
int main(){
int term;
cout<<"Enter a term to evaluate: ";
cin>>term;
estimate_e(term);}
Python:
def factorial(number):
if number == 0:
return 1
return number * factorial(number-1)
def estimate_e(term):
if not term:
return 0
else:
return (1 / factorial(term-1)) + estimate_e(term-1)
number = int(input("Enter how many terms to evaluate "))
print("e: ", estimate_e(number))
c)
C++
#include <iostream>
using namespace std;
int main(){
float terms, sumSeries, series;
int i, number;
cout << " Input the value of x: ";
cin >> number;
cout << " Input number of terms: ";
cin >> terms;
sumSeries = 1;
series = 1;
for (i = 1; i < terms; i++) {
series = series * number / (float)i;
sumSeries = sumSeries + series; }
cout << " The sum is : " << sumSeries << endl; }
Python
def ePowerx(number,terms):
sumSeries = 1
series =1
for x in range(1,terms):
series = series * number / x;
sumSeries = sumSeries + series;
return sumSeries
num = int(input("Enter a number: "))
term=int(input("Enter a number: "))
print("e^x: ",ePowerx(num,term))
Explanation:
a)
The program has a method factorial that takes numbers as parameter and computes the factorial of that number by using recursion. For example if the number = 3
The base case is if (number == 0)
and
recursive is return number * factorial(number - 1);
Since number = 3 is not equal to zero so the method calls itself recursively in order to return the factorial of 3
return 3* factorial(3- 1);
3 * factorial(2)
3* [2* factorial(2- 1) ]
3 * 2* [ factorial(1)]
3 * 2 * [1* factorial(1- 1) ]
3 * 2 * 1* [factorial(0)]
Now at factorial(0) the base condition is reached as number==0 So factorial(0) returns 1
Now the output is:
3 * 2 * 1* 1
return 6
So the output of this program is
Factorial of 3 is 6
b)
The method estimate_e takes a number i.e. num as parameter which represents the term and estimates the value of the mathematical constant e
The for loop iterates through each term. For example num = 3
then
e = e + 1/factorial(i);
The above statement calls works as:
e = 1 + 1/1! +1/2!
since the number of terms is 3
e is initialized to 1
i is initialized to 1
So the statement becomes:
e = 1 + 1/factorial(1)
factorial function is called which returns 1 since factorial of 1 is 1 So,
e = 1 + 1/1
e = 2
Now at next iteration at i = 2 and e = 2
e = 2 + 1/factorial(2)
e = 2 + 1/2
e = 2.5
Now at next iteration at i = 3 and e =3
e = 3 + 1/factorial(3)
e = 3 + 1/6
e = 3.16666
So the output is:
e: 3.16666
c)
The program computes the sum of series using formula:
e^x = 1 + x/1! + x^2/2! + x^3/3! +...
The for loop iterates till the number of terms. Lets say in the above formula x is 2 and number of terms is 3. So the series become:
e^x = 1 + x/1! + x^2/2!
So number = 2
terms = 3
series =1
sumSeries = 1
i = 1
The statement series = series * number / (float)i; works as following:
series = 1 * 2 /1
series = 2
sumSeries = sumSeries + series;
sumSeries = 1 + 2
sumSeries = 3
At next iteration: i=2, series =2 , sumSeries =3
series = 2 * 2/2
series = 2
sumSeries = 3 + 2
sumSeries = 5
Now the loop breaks as i=3
So output returns the value of sumSeries i.e. 5
Output:
e^x: 5
A ________ topology uses more than one type of topology when building a network. crossover multiple-use fusion hybrid
Answer:
hybrid topology
Explanation:
The type of topology that is being described is known as a hybrid topology. Like mentioned in the question this is an integration of two or more different topologies to form a resultant topology which would share the many advantages and disadvantages of all the underlying basic topologies that it is made up of. This can be seen illustrated by the picture attached below.
1.16 LAB: Input: Welcome message Write a program that takes a first name as the input, and outputs a welcome message to that name. Ex: If the input is Pat, the output is:
Answer:
Following are the program to this question:
val=input("")#defining val variable that inputs value
print('Hello',val,', we welcome you...')#defining print method, that print input value with the message
Output:
Pat
Hello Pat , we welcome you...
Explanation:
In the above given, python code a "val" variable, and the print that is inbuilt method is declared, inside the "val" variable the input method is used, which is used to input the value from the user side.
In the next line, the print method has declared, which is used to print the value with the message.
Given the ever-changing cloud services, it is tough to know how to design a sustainable cloud strategy.
a) true
b) false
Answer:
True
Explanation:
Due to the ever-changing cloud services, designing a sustainable cloud strategy is tough. Some factors that makes it look tough:
1. Choosing suitable cloud platforms that will be sustainable over a long period of time.
2. Availability of a cloud design specialist and experts: Getting a cloud specialist who can work out a sustainable design is tough itself.
Every corporate organization must take adequate caution when choosen a cloud design. This is to enable them have something sustainable as a result of the ever-changing cloud services.
Training a model using labeled data and using this model to predict the labels for new data is known as ____________.
Answer:
supervised learning
Explanation:
This process is known as supervised learning. This refers to the machine learning task of learning a function that maps an input to an output based on example input-output pairs. In other words, by teaching it a single process it is able to repeat and predict the same process or predict the output based on the inputs that are being implemented by referring to the initially learned function.
The 6 steps for PowerPoint competency from the TED talk in the module "How to Avoid Death by PowerPoint."?
Answer:
1. Do some presentation preparation work
2. Set the right tone and end on a high note.
3. Create sleek and stylish slides.
4. Get your audience to focus.
5. Its all about you.
Explanation:
1. Do some presentation preparation work:
A good presentation begins, not with slides, but with a pencil and paper. Research your audience’s background, interests and capabilities. What do they already know, for instance, and what can they learn from you?
2. Set the right tone and end on a high note:
You have no more than 30 seconds to secure your audience’s attention. So, what attention-grabbing opener will you use?
Visual communications expert Curtis Newbold suggests “a fascinating quote; an alarming or surprising statistic; asking your audience a question; telling a relevant and funny joke… an imaginary scenario; or a demonstration''.
3. Create sleek and stylish slides:
Once you have your story down, you can start to design your slides.
Before you do, it’s important to think about the practicalities. Will they, for instance, be displayed Widescreen with a 16:9 ratio? Or Standard with 4:3? This might seem like a small detail, but it can make a huge difference in terms of visual impact.
4. Get your audience to focus:
The most important thing is to grab your audience’s attention straight away – and then maintain it! You want your audience to go away having learned something. So, make it as easy as possible for people to grasp your message “from the off”!
5. Its all about you:
Finally, remember that, ultimately, it’s you that the audience should be paying attention to, not your slides!
PowerPoint can be used to create great visual aids, but the success of your presentation is determined by the way you deliver them. So, tell your story with a confident, compelling physical presence, and master it by rehearsing it 10 to 15 times.
How do diverse regulatory practices impede the integration process in a global information system (GIS)
Answer:
Following are the explanation to this question:
Explanation:
In the various regulatory procedures were also simply corporate initiatives, as well as their analytical application by using the open standards users could even solve its problematic situation. It may not work forever, and it is some type of temporary fix.
All such activities include the state or country-related problems only with the Global Information System results. Or in various countries police forces are different. All these price differences thus help the development of incorporation into one of GIS.
Write a second constructor as indicated. Sample output:User1: Minutes: 0, Messages: 0User2: Minutes: 1000, Messages: 5000// ===== Code from file PhonePlan.java =====public class PhonePlan { private int freeMinutes; private int freeMessages; public PhonePlan() { freeMinutes = 0; freeMessages = 0; } // FIXME: Create a second constructor with numMinutes and numMessages parameters. /* Your solution goes here */ public void print() { System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages); return; }}// ===== end =====// ===== Code from file CallPhonePlan.java =====public class CallPhonePlan { public static void main (String [] args) { PhonePlan user1Plan = new PhonePlan(); // Calls default constructor PhonePlan user2Plan = new PhonePlan(1000, 5000); // Calls newly-created constructor System.out.print("User1: "); user1Plan.print(); System.out.print("User2: "); user2Plan.print(); return; }}// ===== end =====
Answer:
public PhonePlan(int numMinutes, int numMessages) {
freeMinutes = numMinutes;
freeMessages = numMessages;
}
Explanation:
Create a constructor that takes two parameters, numMinutes and numMessages
Inside the constructor, set numMinutes to freeMinutes and numMessages to freeMessages.
With this constructor, we are able to create PhonePlan objects that take parameters and different options as seen in the output. We can set any values for minutes and messages in the constructor.
Answer:
PhonePlan::PhonePlan(int numMinutes, int numMessages) {
freeMinutes = numMinutes;
freeMessages = numMessages;
}
Explanation: For C++
PhonePlan::PhonePlan(int numMinutes, int numMessages) {
^^^^^^^^^^^^
you need that
freeMinutes = numMinutes;
freeMessages = numMessages;
}
The parent_directory function returns the name of the directory that's located just above the current working directory. Remember that '..' is a relative path alias that means "go up to the parent directory". Fill in the gaps to complete this function.
import os
def parent_directory():
# Create a relative path to the parent
# of the current working directory
dir = os.getcwd()
relative_parent = os.path.join(dir, ___)
# Return the absolute path of the parent directory
return os.path.dirname(relative_parent)
print(parent_directory())
Answer:
Following are the complete code to this question:
import os #import package
def parent_directory():#defining a method parent_directory
dir = os.getcwd()#defining dir that stores the getcwd method value
relative_parent = os.path.join(dir) #defining relative_parent variable that uses join method to adds directory
return os.path.dirname(relative_parent)#use return keyword to return directory name
print(parent_directory())#use print method to call parent_directory method
Output:
/
Note:
This program is run the online compiler that's why it will return "/"
Explanation:
In the given Python code, we import the "os" package, after that a method "parent_directory" is defined, which uses the dir with the "getcwd" method that stores the current working directory.
After that "relative_parent" variable is declared, which uses the join method to store the directory value and use the return keyword to returns its value. In the next step, the print method is used, which calls the method.Functions are collection of code segments that are executed when called or evoked.
The complete function in Python, where comments are used to explain each line is as follows:
#This imports the os module
import os
#This defines the parent_directory function
def parent_directory():
#This gets file directory
dir = os.getcwd()
#This gets the complete directory
relative_parent = os.path.join(dir)
#This returns the directory name
return os.path.dirname(relative_parent)
print(parent_directory())
Read more about python functions at:
https://brainly.in/question/10211834
Merge arrays A and B into array C using merge sort algorithm. Give final sorted numbers of C using colored numbers without showing intermediate steps. For example, your answer can be [1, 3, 3, 5, 7, 7, 9, 9, 13, 25] or [1, 3, 3, 5, 7, 7, 9,9, 13, 25), or another variation. void merge(int all, int aux[], int lo, int mid, int hi) / for (int k = lo; k<= hi; k++) aux [k] a[k]; int i lo, j = mid+1; for (int k lo; k<-hi; k++) if (i > mid) ak) else if (1 > hi) a[k] else if (small (aux(j), aux[1])) a[k] else ak aux[j++); aux (i++); aux [j++); /*++ aux (i++]; 1 j++
Answer:
Explanation:
Given code:-
#include<iostream>
using namespace std; //namespace
#define RED "\033[31m" /* Red */
#define BLUE "\033[34m" /* Blue */ //color definition
#define WHITE "\033[37m" /* White */
void mergeArrays(int arr1[], int arr2[], int n1, int n2, int arr3[])
//merger sort
{
int i = 0, j = 0, k = 0;
while (i<n1 && j <n2) //iterate over both array
{
if (arr1[i] < arr2[j]) //iff array 1 element is larger
{
arr3[k] = arr1[i]; //assign to a3
k++;
i++;
}
else
{
arr3[k] = arr2[j]; //else assign array 2 to a3
j++;
k++;
}
}
//say the array turns out to br of different sizes
//let us copy the remaining elemnt to array 3
while (i < n1)
{
arr3[k] = arr1[i];
i++;
k++;
}
while (j < n2)
{
arr3[k] = arr2[j];
k++;
j++;
}
}
int main(){
int A[4] = {3,5,7,9}; //array 1 assignment
int a_size = 4;
int b_size = 6;
int B[6] = {1,3,7,9,13,25}; //array 2 assignment
int C[10]; //array 3 declearation
int a_count = 0;
int b_count = 0; //counter for both array index
mergeArrays(A,B,a_size,b_size,C); //merger function applied;
cout<<WHITE<<"A: ";
for(int i = 0; i<4; i++){
cout<<RED<<A[i]<<" ";
}
cout<<endl<<WHITE<<"B: ";
for(int i = 0; i<6; i++){
cout<<BLUE<<B[i]<<" ";
}
cout<<endl<<WHITE<<"C: ";
for(int i = 0; i<10; i++){ //iterate over C
if(C[i] == A[a_count] && a_count < a_size){
cout<<RED<<C[i]<<" ";
// if element is common in array 1 print in red
a_count++;
}
else if (C[i] == B[b_count] && b_count < b_size){
//say element was similar in array 2, print in blue
cout<<BLUE<<C[i]<<" ";
b_count++;
}
}
cout<<endl;
}
An attack in which the attacker attempts to impersonate the user by using his or her session token is known as:
Answer:
Session hijacking
Explanation:
Session hijacking : Session hijacking is an attack where a user session is taken over by an attacker. A session starts when you log into a service, for example your banking application, and ends when you log out.
GIVING BRANLIEST!!!
John wants to assign a value to the favorite animal variable: favoriteAnimal = Koala but gets an error message. What does he need to fix for the code to work?
Add a space between the words in the variable name.
Create a shorter variable name.
Delete the symbol in the string.
Put quotations around the string.
Answer:
put quotations around the string
Explanation:
the animal name, koala, is of data type string and it should be enclosed in " "
delete the symbol
just put it into a processor like python idle
How to help it automation with python professional certificate?
Answer:
Following are the answer to this question:
Explanation:
As we know, that Python is based on Oop's language, it allows programmers to decide, whether method or classes satisfy the requirements.
It's an obvious benefit, in which the system tests the functions, and prevent adverse effects, and clear the syntaxes, which makes them readable for such methods.All the framework uses the python language, that will be used to overcome most every coding task like Mobile apps, desktop apps, data analyses, scripting, automation of tasks, etc.Which type of firewall is ideal for many small office/home office (SOHO) environments?
Answer:
Native OS firewall
Explanation:
Native OS firewall is a computer engineering term that is used in describing a form of the operating system that is in-built or comes from manufacturers of a given device.
Therefore, given that it supports basic functionality, and many, if not all small office/home office (SOHO) environment works with small or little traffic. Hence, for easy navigation and work-around, it is most ideal to use Native OS firewall
5.During a recent network attack, a hacker used rainbow tables to guess network passwords. Which type of attack occurred
Answer:
Rainbow table attack
Explanation:
A rainbow table attack is a type of network attack or hacking where the hacker tries to utilize a rainbow hash table to crack the passwords in a database system. A rainbow table itself is a hash function used in cryptography for saving important data in a database. Especially passwords.
In this process, sensitive data are hashed two or multiple times with the same key or with different keys so as to avoid rainbow table attack. In a rainbow table attack, the hacker simply compares the hash of the original password against hashes stored in the rainbow table and when they find a match, they then identify the password used to create the hash.
Define algorithm
Write a small algorithm
Answer:
an algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem, based on conducting a sequence of specified actions. A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.
Answer:
a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
Explanation:
You are hired to create a simple Dictionary application. Your dictionary can take a search key from users then returns value(s) associated with the key. - Please explain how you would implement your dictionary. - Please state clearly which data structure(s) you will use and explain your decision. - Please explain how you communicate between the data structures and between a data structure and an interface.
Answer:
The application should have a form user interface to submit input, the input is used to query a database, if the input matches a row in the database, the value is displayed in the application.
Explanation:
The data structure in the database for the dictionary application should be a dictionary, with the input from the user as the key and the returned data as the value of the dictionary.
The dictionary application should have a user interface form that submits a query to the database and dictionary data structure returns its value to the application to the user screen.
Code written by computer programmers is translated to binary code, so computers can understand the instructions. True or False
Answer:
True
Explanation:
High-level languages such as Java, C++, Ruby, Python, etc need to be translated into binary code so a computer can understand it, compile and execute them.
Machine language is the only language that is directly understood by the computer because it is written in binary code. But writing codes in Machine Language is tiring, tedious, and obsolete as no one really uses it anymore.
Answer:
True
Explanation:
FLVS intro to Programming honors
How does enforce password history and minimum password age work together to keep a network environment secure?
Answer:
The Enforce Password History and Minimum Password Age works together by preventing a person from changing the password many times and using an old password.
Explanation:
Minimum Password Age works to stop a user from modifying an existing password numerous times so that it will bypass enforce password history and asked to reset the password.
The Enforce Password History policy works to prevent a user from making use of an old password by setting limits on the number of remembered passwords. This helps users from using old and easily guessed passwords which can leave them vulnerable to network attacks.
AddAll - Adds all the doubles in the string with each other. Note every double is separated by a semi-colon. AddAll("1.245;2.9")=>4.145 double AddAll(const char* str) struct Sale char Person[100]; double sale; double tax; struct SaleStatistic double average Sale; double totalSale; double totalTax; (4) AddAl - Adds all the doubles in the string with semi-colon. AddAll("1.245;2.9")=>4.145 double AddAll(const char* str) { ww struct Sale { char Person[100]; double sale; double tax; }; struct SaleStatistic -- double average Sale: double totalSale: double totalTax:
Answer: provided below
Explanation:
The code is provided below/
// the method to add all double value in the string
double AddAll(const char *str)
{
double total = 0;
vector<string> vec;
stringstream strStream(str);
while (strStream.good())
{
string substr;
getline(strStream, substr, ';');
vec.push_back(substr);
}
for (size_t i = 0; i < vec.size(); i++)
{
total = total + stod(vec[i]);
}
return total;
}
Program code with addition of the above for testing is provided thus
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
//addin all double value in syring
double AddAll(const char *str)
{
double total = 0;
vector<string> vec;
stringstream strStream(str);
while (strStream.good())
{
string substr;
getline(strStream, substr, ';');
vec.push_back(substr);
}
for (size_t i = 0; i < vec.size(); i++)
{
total = total + stod(vec[i]);
}
return total;
}
int main()
{
//method calling and display result
cout<<AddAll("1.245;2.9");
}
This gives output as:
4.145
Packet ________ is a form of protection for your computer that looks at each packet that comes into your computer network. screening scanning examination viewing
Answer:
screening
Explanation:
Packet screening also known as packet filtering wall is a package that works at the network layer of the OSI model. It screens IP addresses and packet options and its firewall option allows it to block or allow access into the computer, based on what it has detected.
To achieve this, it can employ the dynamic-packet filtering where ports are opened when it is really necessary and then closed. Static-packet filtering in which rules are set manually and the stateful-paket filtering where packets have to move through some sequence.
when will you need to use a tuple data structure rather than a list of data structure
Answer:
They can always be easily promoted to named tuples. Likewise, if the collection is going to be iterated over, I prefer a list. If it's just a container to hold multiple objects as one, I prefer a tuple. The first thing you need to decide is whether the data structure needs to be mutable or not
Which of the following are true statements about collisions in hashing? Linear probing can cause secondary collisions. Higher space utilization tends to cause more collisions.
Answer:
hello the options to your question is incomplete below are the options
A. Linear probing causes secondary collisions.
B. Higher space utilization tends to cause more collisions.
C. Chained entries will be ordered by key.
D. (a) and (b).
E. All of the above.
answer : (a) and (b) --- D
Explanation:
The true statements about collisions in hashing are ;Linear probing causes secondary collisions and Higher space utilization tends to cause more collisions.
collisions in hashing is when two data sets whom are distinctively different have the same hash value or checksum. the collision in hashing can be resolved by checking the hash table for an open slot to keep the data set that caused the collision.
RAID level ________ refers to disk arrays with striping at the level of blocks, but without any redundancy. A. 0 B. 1 C. 2 D. 3
Answer:
A. 0
Explanation:
RAID level zero refers to disk arrays with striping at the level of blocks, but without any redundancy.
RAID ZERO (disk striping) : This is the process of dividing a body of data into blocks and also spreading the data blocks across multiple storage devices, such as hard disks or solid-state drives (SSDs), in a redundant array of independent disks (RAID) group.
To print a budget:________.
1. From the Company Center, select Company & Financials > Budgets
2. From the Reports Center, select Budgets & Forecasts > Budget Overview
3. From the Reports Center, select Company & Financials > Budgets
4. From the Reports Center, select Accountant & Taxes > Budgets
Answer:
2. From the Reports Center, select Budgets & Forecasts > Budget Overview
Explanation:
In order to print a budget, the step is: From the Reports Center, select Budgets & Forecasts > Budget Overview
A technician mistakenly uninstalled an application that is crucial for the productivity of the user.
Which of the following utilities will allow the technician to correct this issue?
A. System Restore
B. System Configuration
C. Component Services
D. Computer Management
The utility that allows the technician to correct this issue is system restoration. The correct option is A.
What does a system restore?System Restore is a tool for safeguarding and repairing computer software. System Restore creates Restore Points by taking a “snapshot” of some system files and the Windows registry.
Type recovery into the Control Panel search box. Choose Recovery > System Restore. Select Next in the Restore system files and settings window. Select the desired restore point from the list of results, and then click Scan for affected programs.
The Restore Process copies data from a source (one or more Archive files) to a destination (one or more tables in a database). A Restore Process consists of two phases. First, identify one or more Archive Files containing the data to be recovered and choose the desired data.
Therefore, the correct option is A. System Restore.
To learn more about system restoration, refer to the link:
https://brainly.com/question/27960518
#SPJ5
Write Album's PrintSongsShorterThan() to print all the songs from the album shorter than the value of the parameter songDuration. Use Song's PrintSong() to print the songs.
#include
#include
#include
using namespace std;
class Song {
public:
void SetNameAndDuration(string songName, int songDuration) {
name = songName;
duration = songDuration;
}
void PrintSong() const {
cout << name << " - " << duration << endl;
}
string GetName() const { return name; }
int GetDuration() const { return duration; }
private:
string name;
int duration;
};
Answer:
Here is the function PrintSongsShorterThan() which prints all the songs from the album shorter than the value of the parameter songDuration.
void Album::PrintSongsShorterThan(int songDuration) const { //function that takes the songDuration as parameter
unsigned int i;
Song currSong;
cout << "Songs shorter than " << songDuration << " seconds:" << endl;
for(int i=0; i<albumSongs.size(); i++){
currSong = albumSongs.at(i);
if(currSong.GetDuration()<songDuration){ //checks if the song duration of the song from album is less than the value of songDuration
currSong.PrintSong(); } } } //calls PrintSong method to print all the songs with less than the songDuration
Explanation:
Lets say the songDuration is 210
I will explain the working of the for loop in the above function.
The loop has a variable i that is initialized to 0. The loop continues to execute until the value of i exceeds the albumSongs vector size. The albumSongs is a Song type vector and vector works just like a dynamic array to store sequences.
At each iteration the for loop checks if the value of i is less than the size of albumSongs. If it is true then the statement inside the loop body execute. The at() is a vector function that is used to return a reference to the element at i-th position in the albumSongs.
So the album song at the i-th index of albumSongs is assigned to the currSong. This currSong works as an instance. Next the if condition checks if that album song's duration is less than the specified value of songDuration. Here the method GetDuration() is used to return the value of duration of the song. If this condition evaluates to true then the printSong method is called using currSong object. The printSong() method has a statement cout << name << " - " << duration << endl; which prints/displays the name of the song with its duration.
The musicAlbum is the Album object to access the PrintSongsShorterThan(210) The value passed to this method is 210 which means this is the value of the songDuration.
As we know that the parameter of PrintSongsShorterThan method is songDuration. So the duration of each song in albumSongs vector is checked by this function and if the song duration is less than 210 then the name of the song along with its duration is displayed on the output screen.
For example if the album name is Anonymous and the songs name along with their duration are:
ABC 400
XYZ 123
CDE 300
GHI 200
KLM 100
Then the above program displays the following output when the user types "quit" after entering the above information.
Anonymous
Songs shorter than 210 seconds: XYZ - 123
GHI - 200
KLM - 100
Notice that the song name ABC and CDE are not displayed because they exceed the songDuration i.e. 210.
Many clustering algorithms that automatically determine the number of clusters claim that this is an advantage. List two situations in which this is not the case
Answer: to vibe the rest
Explanation:
Processors for most mobile devices run at a slower speed than a processor in a desktop PC.
A. True
B. False
Hope this helps you! :)
The ans is A which is TRUE
(Was a tricky ques for some but... u gotta learn it!)
PLS MARK AS BRAINLIEST!
Processors for most mobile devices run at a slower speed than a processor in a desktop PC, therefore, the statement is true.
The Processor is simply known as the heart of the computer. It enables the computer to be able to execute its command.It should be noted that the processors for most mobile devices run at a slower speed than a processor in a desktop PC. It should be noted that mobile devices are smaller than computers. There is a lot of heat that is generated by the running mobile processor in mobile phones and this limits the speed of the mobile phones.In conclusion, once there's a limitation of the speed, there's a slower performance of the mobile phone.
Read related link on:
https://brainly.com/question/614196
You are given an array of integers a. A new array b is generated by rearranging the elements of a in the following way:
b[0] is equal to a[0];
b[1] is equal to the last element of a;
b[2] is equal to a[1];
b[3] is equal to the second-last element of a;
and so on.
Your task is to determine whether the new array b is sorted in strictly ascending order or not.
Example
For a = [1, 3, 5, 6, 4, 2], the output should be alternatingSort(a) = true.
The new array b will look like [1, 2, 3, 4, 5, 6], which is in strictly ascending order, so the answer is true.
For a = [1, 4, 5, 6, 3], the output should be alternatingSort(a) = false.
The new array b will look like [1, 3, 4, 6, 5], which is not in strictly ascending order, so the answer is false.
Input/Output
[execution time limit] 3 seconds (java)
[input] array.integer a
The given array of integers.
Guaranteed constraints:
1 ≤ a.length ≤ 105,
-109 ≤ a[i] ≤ 109.
[output] boolean
A boolean representing whether the new array bwill be sorted in strictly ascending order or not.
Answer:
Explanation:
Take note to avoid Indentation mistake which would lead to error message.
So let us begin by;
import java.util.*; ------ using Java as our programming language
class Mutation {
public static boolean alternatingSort(int n , int[] a)
{
int []b = new int[n];
b[0]=a[0];
int j=1,k=0;
for(int i=1;i<n;i++)
{
if(i%2==1)
{
b[i]=a[n-j];
j++;
}
else
b[i]=a[++k];
}
for(int i=0;i<n;i++)
{
System.out.print(b[i]+" ");
}
System.out.print("\n");
for(int i=1;i<n;i++)
{
if(b[i]<=b[i-1])
return false ;
}
return true;
}
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int []a = new int [n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
System.out.println(alternatingSort(n,a));
}
}
This code should give you the desired result (output).
The program is an illustration of Arrays.
Arrays are variables that are used to hold multiple values using one variable name
The program in Java, where comments are used to explain each line is as follows:
import java.util.Scanner;
public class Main {
//This defines the alternatingSort function
public static boolean alternatingSort(int n , int[] a){
//This creates an array b
int b[] = new int[a.length];
//This populates the first element of array b
b[0]=a[0];
//This initializes two counter variables
int count1 =1,count2 = 0;
//This iterates from 1 to n - 1
for(int i=1;i<a.length;i++){
//This populates array b for odd indices
if(i%2==1){
b[i]=a[n-count1];
count1++;
}
//This populates array b for even indices
else{
b[i]=a[++count2];
}
}
//This iterates from 0 to n - 1
for(int i=0;i<a.length;i++){
//This prints the elements of array b
System.out.print(b[i]+" ");
}
//This prints a new line
System.out.println();
//This iterates from 1 to n - 1
for(int i=1;i<a.length;i++){
//This checks if the elements of array b are strictly in ascending order
if(b[i]<=b[i-1]){
return false ;
}
}
return true;
}
//The main function begins hers
public static void main (String[] args) {
//This creates a Scanner object
Scanner input = new Scanner(System.in);
//This gets input for the length of the array
int n= input.nextInt();
//This creates the array a
int a[] = new int [n];
//The following iteration populates array a
for(int i=0;i<n;i++){
a[i]=input.nextInt();
}
//This calls the alternatingSort function
System.out.println(alternatingSort(n,a));
}
}
Read more about arrays at:
https://brainly.com/question/15683939
Do computers perform disk optimization utilizing the same software
Answer:
All computers perform disk optimization utilizing the same software.