Answer:
Bandwidth delay product = 2500 Kbits
Utilization = 0.02%
Explanation:
We proceed as follows;
From the question, we are given that
band width = 500 Mbps
The bandwidth-delay product is = 500 x 10^6 x 25 x 10^-3
= 2500 Kbits
The system can send 12500 Kbits during the time it takes for the data to go from the sender to the receiver and then back again.
However, the system sends only 2500 bits.
The the link utilization =
2500/(12500 x 10^3) = 0.02%
A large population of ALOHA users manages to generate 50 requests/sec, including both originals and retransmissions. Time is slotted in units of 40 msec.
Required:
a. What is the chance of success on the first attempt?
b. What is the probability of exactly k collisions and then a success?
c. What is the expected number of transmission attempts needed?
Answer:
The answer is below
Explanation:
Given that:
Frame transmission time (X) = 40 ms
Requests = 50 requests/sec, Therefore the arrival rate for frame (G) = 50 request * 40 ms = 2 request
a) Probability that there is success on the first attempt = [tex]e^{-G}G^k[/tex] but k = 0, therefore Probability that there is success on the first attempt = [tex]e^{-G}=e^{-2}=0.135[/tex]
b) probability of exactly k collisions and then a success = P(collisions in k attempts) × P(success in k+1 attempt)
P(collisions in k attempts) = [1-Probability that there is success on the first attempt]^k = [tex][1-e^{-G}]^k=[1-0.135]^k=0.865^k[/tex]
P(success in k+1 attempt) = [tex]e^{-G}=e^{-2}=0.135[/tex]
Probability of exactly k collisions and then a success = [tex]0.865^k0.135[/tex]
c) Expected number of transmission attempts needed = probability of success in k transmission = [tex]e^{G}=e^{2}=7.389[/tex]
Write a C function check(x, y, n) that returns 1 if both x and y fall between 0 and n-1 inclusive. The function should return 0 otherwise. Assume that x, y and n are all of type int.
Answer:
See comments for line by line explanation (Lines that begins with // are comments)
The function written in C, is as follows:
//The function starts here
int check(x,y,n)
{
//This if condition checks if x and y are within range of 0 to n - 1
if((x>=0 && x<=n-1) && (y>=0 && y<=n-1))
{
//If the if conditional statement is true, the function returns 1
return 1;
}
else
{
//If the if conditional statement is false, the function returns 0
return 0;
}
//The if condition ends here
}
//The function ends here
Explanation:
Recall that within the ArrayBoundedQueue the front variable and the rear variable hold the indices of the elements array where the current front and rear elements, respectively, of the queue are stored. Which of the following code sequences could be used to correctly enqueue element into the queue, assuming that enqueue is called on a non-full queue and that the code also correctly increments numElements?
a. numElements++; elements[rear) - element:
b. front++; elements(front) - element:
c. rear = (rear + 1) % elements.length; elements[rear) - element;
d. front = (front + 1) % elements.length; elements[front) - element;
Answer:
c. rear = (rear + 1) % elements.length; elements[rear] = element;
Explanation:
In the above statement:
Name of the array is elements.
rear holds current index of elements array where current rear element of queue is stored. Front are rear are two open ends of the queue and the end from which the element is inserted into the queue is called rear.
element is the element that is required to enqueue into the queue
Enqueue basically mean to add an element to a queue.
Here it is assumed that the queue is not full. This means an element can be added to the queue.
It is also assumed that code also correctly increments numElements.
rear = (rear + 1) % elements.length; This statement adds 1 to the rear and takes the modulus of rear+1 to the length of the array elements[]. This statement specifies the new position of the rear.
Now that the new position of rear is found using the above statement. Next the element can be enqueued to that new rear position using the following statement:
elements[rear] = element; this statement sets the element at the rear-th (new position) index of elements[] array.
For example we have a queue of length 5 and there are already 4 elements inserted into this queue. We have to add a new element i.e. 6 to the queue. There are four elements in elements[] array and length of the array is 5 so this means the queue is not full. Lets say that rear = 3
elements.length = 5
rear = 3
Using above two statements we get.
rear = (rear + 1) % elements.length;
= 3 + 1 % 5
= 4%5
= 4
This computes the new position of rear. So the new position of rear is the 4-th index of elements[]. Now next statement:
elements[rear] = element;
elements[4] = 6
This statement adds element 6 to the 4-th index of elements[] array.
Thus the above statement enqueues element (element 6 in above example) into the queue.
The machine has to be returned to the vendor for proper recycling. Which stage of the hardware lifecycle does this scenario belong to?
Answer:
Decommission/Recycle
Explanation:
This specific scenario that is being described belongs to the final stage of the hardware lifecycle known as Decommission/Recycle. This is when the asset in question has completed its function for an extended period of time and is no longer functioning at maximum efficiency and/or newer hardware has hit the market. Once in this stage, the hardware in question is either repaired or scrapped for resources that can be used to create newer products.
Which is a software configuration management concept that helps us to control change without seriously impeding justifiable change?
Answer:
Baselines
Explanation:
The idea of software configuration management is that of monitoring and controlling changes in the software. The baseline is the standard and formally accepted form of a software item that is meant to be configured. It is like a generally accepted reference point, which could be applied in effecting incremental changes in the software.
There are three types of baselines which are the functional, developmental, and product baselines. Functional baselines provide an overview of the functionality and specifications of a system. The product baseline encompasses both the functional and physical details of the system.
Summary
In this graded assignment, you will write Python programs that use loops to implement various algorithms.
Learning Outcomes
In completing this assignment, you will:
• Gain more experience converting an algorithm expressed using flowchart to one implemented in a Python program.
• Write a Python program using loops
Description
In a previous assignment in this course, you were asked to draw a flowchart for an algorithm that finds the two smallest items in a list, and then another assignment asked you to convert that flowchart to pseudocode.
Here is a pseudocode implementation of that algorithm:
1. min1- list
2. min2 - list,
3. for each item in list
4. if item
5. then if min1
6. then min2
7. else mint
8. else if item
9. then min2
10. output: min1, min2 item item item
Now, implement the algorithm in Python so that it correctly sets the values of min1 and min2 which should hold the two smallest values in the list, though not necessarily in that order.
In the code below, we have provided a list called "list" and initialized min 1 and min2 to hold the first two elements. Write your code starting at line 5 (you can remove the comments starting at line 6, and may need more space than what is provided), and be sure that the values of min1 and min2 are correctly set before the code reaches the "return (min1, min2)" statement on line 11.
As in the previous assignment, we will be using the Coursera automatic grading utility to test your code once you submit this quiz for grading, and this requires it to be within a function. So be sure that all of the code after line 1 is indented, and that you do not have any code after the "return (min 1, min2)" statement.
Keep in mind that the goal here is to write a program that would find the two smallest values of any list, not just the one provided on line 2. That is, don't simply set min 1 and min2 to-2 and -5, which are the two smallest values, but rather write a program that implements the algorithm from the flowchart and correctly sets min1 and min2 before reaching the return (min1, min2)" statement.
As before, you can test your program by clicking the "Run" button to the right of the code to see the results of any "print" statements, such as the one on line 10 which prints min1 and min2 before ending the function. However, please be sure that you do not modify the last two lines of the code block
1. def test(): # do not change this line!
2. list = [4, 5, 1, 9, -2, 0, 3, -5] # do not change this line!
3. min1 = list[0]
4. min2 = list[1]
5.
6. #write your code here so that it sets
7. #min1 and min2 to the two smallest numbers
8. # be sure to indent your code!
9.
10. print(min1, min2)
11. return (min1, min2) # do not change this line!
12. # do not write any code below here
13.
14. test() # do not change this line!
15. # do not remove this line!
Hints: The Python code for this algorithm is very similar to the pseudocode! Just be sure you are using the correct syntax. As in previous activities, don't forget that you can use the "print" function to print out intermediate values as your code is performing operations so that you can see what is happening
If the current date is Monday, February 26, 2017, what will be displayed by the alert dialog box after the following code executes? var thisDay = new Date(); alert(thisDay.toDateString());
Answer:
Mon Feb 26 2017
Explanation:
Since the current date is considered as Monday, February 26, 2017, thisDay will be set to that value.
The toDateString() method returns the first three letters of the name of the day (The first letter is capitalized), the first three letters of the name of the month (The first letter is capitalized), the day of the month as an integer, and the year as an integer (There are spaces between all)
A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a file. The program should output the unique words and their frequencies in alphabetical order. Variations are to track sequences of two words and their frequencies, or n words and their frequencies.
Below is an example file along with the program input and output:
example.txt
I AM SAM I AM SAM SAM I AM
Enter the input file name: example.txt
AM 3
I 3
SAM 3
Answer:
I am writing a Python program.
def concordance(filename): # function that takes a file name as parameter and returns the concordance for that file
file = open(filename,"r") #opens file in read mode
unique={} #creates and empty list
for word in file.read().split(): #loops through every word in the file
if word in unique: # if words is already present in the list
unique[word] += 1 #add 1 to the count of the existing word
else: #if word is not present in the list
unique[word] = 1 #add the word to the list and add 1 to the count of word
file.close(); # close the file
for x in sorted(unique): #sort the list and displays words with frequencies
print(x, unique[x]); #prints the unique words and their frequencies in alphabetical order
#prompts user to enter the name of the file
file_name=input('Enter the input file name: ')
concordance(file_name) #calls concordance method by passing file name to it
Explanation:
The program has a function concordance that takes a text file name as parameter and returns a list of unique words and their frequencies.
The program first uses open() method to open the file in read mode. Here "r" represents the mode. Then creates an empty list named unique. Then the for loop iterates through each word in the file. Here the method read() is used to read the contents of file and split() is used to return these contents as a list of strings. The if condition inside the loop body checks each word if it is already present in the list unique. If the word is present then it adds 1 to the count of that word and if the word is not already present then it adds that unique word to the list and assign 1 as a count to that word. close() method then closes the file. The second for loop for x in sorted(unique): is used to display the list of unique words with their frequencies. sorted() method is used to sort the list and then the loop iterates through each word in the list, through x, which acts like an index variable, and the loop displays each word along with its frequency.
A security administrator is investigating a report that a user is receiving suspicious emails. The user's machine has an old functioning modem installed. Which of the following security concerns need to be identified and mitigated? (Select TWO).
a) Vishing
b) Whaling
c) Spear phishing
d) Pharming
e) War dialing
f) Hoaxing
Answer:
Spear Phishing and War Dialing
Explanation:
So let's tackle these one at a time.
Vishing is simply any type of message (i.e., email, text, phone call, etc.) that appears to be from a trusted source but is not.
Whaling is simply a spear phishing attack of a high-value target such as a CEO or someone with high-level access at a company.
Spear phishing is simply a targeted phishing attack, usually towards a specific person or group of people. (Phishing attack is simply a social attack to try and gain unauthorized access to a resource).
Pharming is an attack that attempts to redirect website traffic to a fake site.
War dialing is a technique to automatically scan a list of numbers in an area in attempt to search for exposed modems, computers, board systems, or fax machines, in order to breach the network.
Hoaxing is simply a social attack that describes a serious threat in attempts to retrieve unauthorized access or money from a victim. (Think microsoft tech support scams)
Now that we have defined these things, let's identify the possible threats that need to be reported.
(a) Vishing? The sec admin report doesn't mention the source of the message so we cannot associate this one
(b) Whaling? The sec admin report says a user, implying someone not high up in the company, but doesn't say it's not someone high up. This is possible.
(c) Spear phishing? The sec admin report says a user, implying that only this user is being targeted so this is definitely valid.
(d) Pharming? The sec admin report says nothing about site redirection.
(e) War dialing? The sec admin report doesn't say anything about unauthorized scanning; however, it mentions the user has an old functioning modem, so this is possible.
(f) Hoaxing? The sec admin report doesn't mention a pop up in the email or the content of the email so we are uncertain.
Thus with these considerations, the two threats that are identified and need mitigation are Spear phishing and War Dialing/Whaling. Note that we aren't positive of the war dialing or whaling, but a case could be made for either; however, given the modem information, the question seems to indicate war dialing.
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.
How I to turn this ''loop while'' in ''loop for''?
var i = 0;
while (i < 20) {
var lineY = 20 + (i * 20);
line(0, lineY, 400, lineY);
i++;
}
Answer:
for (var i = 0; i <20; i++)
{
var lineY = 20 + (i * 20);
line(0, lineY, 400, lineY);
}
Explanation:
To turn the loop while to for loop, you start by considering the iterating variable i and its iterating operations which are;
var i = 0; while (i < 20) and i++;
Where var i = 0; is the initializing statement
(i < 20) is the conditional statement
i++ is the increment
The next is to combine these operations to a for loop; using the following syntax: for(initializing; condition; increment){}
This gives: for(var i = 0; i<20; i++)
Hence, the full code snippet is:
for (var i = 0; i <20; i++)
{
var lineY = 20 + (i * 20);
line(0, lineY, 400, lineY);
}
Velma is graduating from Ashford at the end of next year. After she completes her final class, she will reward herself for her hard work with a week-long vacation in Hawaii. But she wants to begin saving money for her trip now. Which of the following is the most effective way for Velma to save money each month?
This question is incomplete because the options are missing; here are the options for this question:
Which of the following is the most effective way for Velma to save money each month?
A. Automatically reroute a portion of her paycheck to her savings account.
B. Manually deposit 10% of her paycheck in her savings account.
C. Pay all of her bills and then place the remaining money in her savings account.
D. Pay all of her bills and then place the remaining money in her piggy bank.
The correct answer to this question is A. Automatically reroute a portion of her paycheck to her savings account.
Explanation:
In this case, Velma needs to consistently save money for her vacation as this guarantees she will have the money for the trip. This means it is ideal every month she contributes consistently to her savings for the vacation.
This can be better be achieved by automatically rerouting a part of her paycheck for this purpose (Option A) because in this way, every month the money for the vacations will increase and the amount of money will be consistent, which means Velma will know beforehand the money she will have for the vacation. Moreover, options such as using a piggy bank or paying the bills and using the rest for her savings, do not guarantee she will contribute to the savings every month, or she will have the money she needs at the end.
C++ Fibonacci
Complete ComputeFibonacci() to return FN, where F0 is 0, F1 is 1, F2 is 1, F3 is 2, F4 is 3, and continuing: FN is FN-1 + FN-2. Hint: Base cases are N == 0 and N == 1.
#include
using namespace std;
int ComputeFibonacci(int N) {
cout << "FIXME: Complete this function." << endl;
cout << "Currently just returns 0." << endl;
return 0;
}
int main() {
int N = 4; // F_N, starts at 0
cout << "F_" << N << " is "
<< ComputeFibonacci(N) << endl;
return 0;
}
Answer:
int ComputeFibonacci(int N) {
if(N == 0)
return 0;
else if (N == 1)
return 1;
else
return ComputeFibonacci(N-1) + ComputeFibonacci(N-2);
}
Explanation:
Inside the function ComputeFibonacci that takes one parameter, N, check the base cases first. If N is eqaul to 0, return 0. If N is eqaul to 1, return 1. Otherwise, call the ComputeFibonacci function with parameter N-1 and N-2 and sum these and return the result.
For example,
If N = 4 as in the main part:
ComputeFibonacci(4) → ComputeFibonacci(3) + ComputeFibonacci(2) = 2 + 1 = 3
ComputeFibonacci(3) → ComputeFibonacci(2) + ComputeFibonacci(1) = 1 + 1 = 2
ComputeFibonacci(2) → ComputeFibonacci(1) + ComputeFibonacci(0) = 1 + 0 = 1
*Note that you need to insert values from the bottom. Insert the values for ComputeFibonacci(1) and ComputeFibonacci(0) to find ComputeFibonacci(2) and repeat the process.
Why is a DNS cache poisoning attack dangerous? Check all that apply. A. Errrr...it's not actually dangerous. B. It allows an attacker to redirect targets to malicious webservers. C. It allows an attacker to remotely controle your computer. D. It affects any clients querying the poisoned DNS server.
Answer:
(B) It allows an attacker to redirect targets to malicious webserver.
(D) It affects any clients querying the poisoned DNS server.
Explanation:
DNS cache poisoning is a serious type of attack that is designed to exploit the vulnerabilities inherent in a Domain Name Server (DNS) where a user is redirected from a real server to a fake one. It is also called DNS spoofing.
Normally, when your browser tries to visits a website through a given domain name, it goes through the DNS server. A DNS server maintains a list of domain names and their equivalent Internet Protocol addresses. This server (DNS) then responds to the request with one or more IP addresses for the browser to reach the website through the domain name.
The computer browser then get to the intended website through the IP address.
Now, if the DNS cache is poisoned, then it has a wrong entry for IP addresses. This might be via hacking or a physical access to the DNS server to modify the stored information on it. Therefore, rather than responding with the real IP address, the DNS replies with a wrong IP address which then redirects the user to an unreal website.
Although they might not be able to control your computer remotely as long as you are not trying to visit a web page via the poisoned information, there are other dangers attached to this type of attack.
Once the DNS server has been poisoned, any client trying to query the server will also be affected since there is no direct way of knowing if the information received from the server is actually correct.
a software development management tool that easily integrates into his business’s enterprise software/information system
Answer:
Enterprise software/system
Explanation:
Enterprise software which is also known as Enterprise Application Software (EAS) is computer software that its primary function is to meet the needs of an organization rather than that of an individual.
EAS or Enterprise System is the software development management tool that easily integrates into a business' enterprise software system.
g 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:
I am writing a C++ program:
#include <iostream> //to use input output functions
#include<iomanip> // to format the output
using namespace std; // to identify objects like cin cout
void calculateCharge(double weight, double distance); // function prototype
int main(){ //start of main() function body
double w = 0.0, t = 0.0; // w variable is for weight and t is for total
unsigned int d = 0; // d variable is to hold the value of distance
calculateCharge(w, d); } //calls calculateCharge method by passing weight and distance values to this method
void calculateCharge(double weight, double distance){ //method that takes weight and distance as parameters and compute the shipping charge
double charge = 0.0; //to store the value of shipping charges
do { // do while loop to handle multiple packages until a weight of 0 is entered
cout << "Enter weight: " << endl; //prompts user to enter weight
cin >> weight; //reads the input weight value
if (weight == 0){ // if the value of weight is equal to 0
break; } // the loop breaks if value of weight is 0
cout << "Enter distance: " << endl; // if value of weight is not zero then the program precedes by prompting user to enter the value of distance
cin >> distance; //reads the input distance value
cout << fixed << setprecision(2) << endl; //set the precision to 2 means the sets the number of digits of an output to 2 decimal places
if(weight <= 2) //if the value of weight is less than or equals to 2
charge = (distance/500) * 3.10; //compute the charge by this formula
else if(weight > 2 && weight <= 6) //if weight is over 2 kg but not more than 6 kg
charge = (distance/500) * 4.20; //charge is computed by multiplying value of distance to that of weight and if distance is greater than 500 then it is divided by 500 first
else if(weight > 6 && weight <= 10) // if weight is over 6 kg but not more than 10 kg
charge = (distance/500) * 5.30; //compute shipping charges by this formula
else //if weight is over 10 kg
charge = (distance/500) * 6.40; // compute shipping charge by multiplying value of distance to that of 6.40 weight value and if distance is greater than 500 then distance is divided by 500 first
cout << "Shipping charges: $" << charge << "\n"; //display the computed shipping charge
} while (weight != 0); //the loop continues to execute until weight 0 is entered
}
Explanation:
The program is explained in the comments mentioned above. The program has a main() function that declares variable for weight, distance and total and then calls calculateCharge() method passing weight and dsitance in order to compute and return the shipping charge.
In calculateCharge() the user is prompted to enter the values for weight and distance. Then the based on the value of weight , the shipping charge is computed. Shipping charge is computed by multiplying the weight with distance. The distance is assumed to be 500 but if the distance entered by user exceeds 500 then the distance value is divided by 500 and then multiplied by the specified weight (according to if or else if conditions) in order to compute shipping charge. The program has a do while loop that keeps taking input from user until the user enters 0 as the value of weight.
The screenshot of the program and its output is attached.
Open up your database administraton GUI, and use the appropriate SQL Query Tool to write the SQL CREATE statement for your BOOK_TAGS table. You can either write the script manually and execute it through pgAdmin or you can create the table by using pgAdmin's wizard.
Afterwards, insert one row of dummy data that adds a tag to the sample book in the BOOKS table.
Answer:
nxlskshwhhwwlqlqoejebx znznxjslaa
Boolean expressions control _________________ Select one: a. recursion b. conditional execution c. alternative execution d. all of the above
Answer:
Option D, all of the above, is the right answer.
Explanation:
A Boolean expression is an expression in Computer Science. It is employed in programming languages that create a Boolean value when it is evaluated. There may be a true or false Boolean value. These expressions correspond to propositional formularies in logic. In Boolean expression, the expression 3 > 5 is evaluated as false while 5 > 3 is evaluated as true
Boolean expressions control all of the above method execution and as such option d is correct.
What is Boolean expressions?A Boolean expression is known to be a kind of logical statement that is said to be one of the two options that is it can be TRUE or FALSE .
Conclusively, Note that Boolean expressions are used to compare two or more data of any type only if both parts of the expression have equal basic data type. Boolean expressions control recursion, conditional execution and alternative execution.
Learn ore about Boolean expressions from
https://brainly.com/question/25039269
A printer is connected locally on Computer1 and is shared on the network. Computer2 installs the shared printer and connects to it. Computer1 considers the printer to be a(n) ________________ printer, and Computer2 considers the printer to be a(n) ________________ printer.
Answer:
A printer is connected locally on Computer1 and is shared on the network. Computer2 installs the shared printer and connects to it. Computer1 considers the printer to be a(n) _____local___________ printer, and Computer2 considers the printer to be a(n) _____network___________ printer.
Explanation:
Any printer installed directly to Computer 1 is a local printer. If this printer is then shared with computers 2 and 3 in a particular networked environment, it becomes a shared printer. For these other computers 2 and 3, the shared printer is a network printer, because it is not locally installed in each of them. There may be some features which network computers cannot use on a shared printer, especially if the printer can scan documents.
What can you do using the start menu in windows 10
Answer:
The start menu in windows 10 has similarities.
Explanation:The windows 10 is start menu and start screen. Installed windows 10 on a PC, the start button after windows appear start menu.Windows app you can access windows apps right the menu. click the left display all apps installed your personal computer. click right to open a window app NEWS,MAIL, or CALENDAR. POWER button at the bottom of the left side, and display the to shut down and restart.
Right click your account name at the top the menu.You add files explorer to taskbar.Simply click the option you needed
Some network applications defer configuration until a service is needed. For example, a computer can wait until a user attempts to print a document before the software searches for available printers.
What is the chief advantage of deferred configuration?
Answer:
The drivers wont be loaded and the deamons will not be running in the background unnecessarily, that makes the processes to run more faster
Explanation:
The chief advantage of deferred configuration or the advantage when some network applications defer configuration until a service is needed is that the drivers won't be loaded and the deamons will not be running in the background unnecessarily or when idle, that makes the processes to run more faster.
Network configuration is the activity which involves setting up a network's controls, flow and operation to assist the network communication of an organization or network owner.
Which is the first step in the process of reading materials critically
Answer:
SQRRR or SQ3R is a reading comprehension method named for its five steps: survey, question, read, recite, and review. The method was introduced by Francis P. Robinson, an American education philosopher in his 1946 book Effective Study. The method offers a more efficient and active approach to reading textbook material
Assemble a Server computer based on your budget (state the amount in Ghana Cedis), discussing the type of components (giving their exact names, model numbers, types, cost, architecture, etc.) you would need and give reasons why you need them.
Answer:
Following are the answer to this question:
Explanation:
The server would be generally a powerful processor instead of a desktop pc. It must choose the Dell server browser to choose a server for industrial applications.
Dell Poweredge R730 has been its pattern. There should be the reason whether these servers are efficient, available, flexible, and support the concept of even a virtual environment. Its same servers are easy to use, as well as the memory will be connected to this server is 8 TB.Which of the following statements represents the number of columns in a regular two-dimensional array named values?
A) values[0].length
B) values.length
C) values.length)
D) values[0].length0
E) values.getColumnLength0)
Answer:
(a) values[0].length
Explanation:
In programming languages such as Java, an array is a collection of data of the same type. For example, a and b below are an example of an array.
a = {5, 6, 7, 9}
b = {{2,3,4}, {3,5,4}, {6,8,5}, {1,4,6}}
But while a is a one-dimensional array, b is a regular two-dimensional array. A two-dimensional array is typically an array of one-dimensional arrays.
Now, a few thing to note about a two-dimensional array:
(i) The number of rows in a 2-dimensional array is given by;
arrayname.length
For example, to get the number of rows in array b above, we simply write;
b.length which will give 4
(ii) The number of columns in a 2-dimensional array is given by;
arrayname[0].length
This is with an assumption that all rows have same number of columns.
To get the number of columns in array b above, we simply write;
b[0].length which will give 3
Therefore, for a regular two-dimensional array named values, the number of columns is represented by: values[0].length
A password checking system that disallows user passwords that are proper names or words that are normally included in a dictionary is an example of _____ with respect to security systems.
Start with the following Python code. alphabet = "abcdefghijklmnopqrstuvwxyz" test_dups = ["zzz","dog","bookkeeper","subdermatoglyphic","subdermatoglyphics"] test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"] # From Section 11.2 of: # Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press. def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1 else: d[c] += 1 return d Copy the code above into your program but write all the other code for this assignment yourself. Do not copy any code from another source. Part 1 Write a function called has_duplicates that takes a string parameter and returns True if the string has any repeated characters. Otherwise, it should return False. Implement has_duplicates by creating a histogram using the histogram function above. Do not use any of the implementations of has_duplicates that are given in your textbook. Instead, your implementation should use the counts in the histogram to decide if there are any duplicates. Write a loop over the strings in the provided test_dups list. Print each string in the list and whether or not it has any duplicates based on the return value of has_duplicates for that string. For example, the output for "aaa" and "abc" would be the following. aaa has duplicates abc has no duplicates Print a line like one of the above for each of the strings in test_dups. Part 2 Write a function called missing_letters that takes a string parameter and returns a new string with all the letters of the alphabet that are not in the argument string. The letters in the returned string should be in alphabetical order. Your implementation should use a histogram from the histogram function. It should also use the global variable alphabet. It should use this global variable directly, not through an argument or a local copy. It should loop over the letters in alphabet to determine which are missing from the input parameter. The function missing_letters should combine the list of missing letters into a string and return that string. Write a loop over the strings in list test_miss and call missing_letters with each string. Print a line for each string listing the missing letters. For example, for the string "aaa", the output should be the following. aaa is missing letters bcdefghijklmnopqrstuvwxyz If the string has all the letters in alphabet, the output should say it uses all the letters. For example, the output for the string alphabet itself would be the following. abcdefghijklmnopqrstuvwxyz uses all the letters Print a line like one of the above for each of the strings in test_miss. Submit your Python program. It should include the following. The provided code for alphabet, test_dups, test_miss, and histogram. Your implementation of the has_duplicates function. A loop that outputs duplicate information for each string in test_dups. Your implementation of the missing_letters function. A loop that outputs missing letters for each string in test_miss. Also submit the output from running your program. Your submission will be assessed using the following Aspects. Does the program include a function called has_duplicates that takes a string parameter and returns a boolean? Does the has_duplicates function call the histogram function? Does the program include a loop over the strings in test_dups that calls has_duplicate on each string? Does the program correctly identify whether each string in test_dups has duplicates? Does the program include a function called missing_letters that takes a string parameter and returns a string parameter? Does the missing_letters function call the histogram function? Does the missing_letters function use the alphabet global variable directly? Does the program include a loop over the strings in test_miss that calls missing_letters on each string? Does the program correctly identify the missing letters for each string in test_miss, including each string that "uses all the letters"?
Answer:
alphabet = "abcdefghijklmnopqrstuvwxyz"
test_dups = ["zzz","dog","bookkeeper","subdermatoglyphic","subdermatoglyphics"]
test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"]
# From Section 11.2 of: # Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.
def histogram(s):
d = dict()
for c in s:
if c not in d:
d[c] = 1
else:
d[c] += 1
return d
#Part 1 Write a function called has_duplicates that takes a string parameter and returns True if the string has any repeated characters. Otherwise, it should return False.
def has_duplicates(stringP):
dic = histogram(stringP)
for key,value in dic.items():
if value>1:
return True
return False
# Implement has_duplicates by creating a histogram using the histogram function above. Write a loop over the strings in the provided test_dups list.
# Print each string in the list and whether or not it has any duplicates based on the return value of has_duplicates for that string.
# For example, the output for "aaa" and "abc" would be the following. aaa has duplicates abc has no duplicates Print a line like one of the above for each of the strings in test_dups.
print("***Implementation of has_duplicates fuction***")
for sTr in test_dups:
if has_duplicates(sTr):
print(sTr+": has duplicates")
else:
print(sTr+": has no duplicates")
#Part 2 Write a function called missing_letters that takes a string parameter and returns a new string with all the letters of the alphabet that are not in the argument string.
#The letters in the returned string should be in alphabetical order. Your implementation should use a histogram from the histogram function. It should also use the global variable alphabet.
#It should use this global variable directly, not through an argument or a local copy. It should loop over the letters in alphabet to determine which are missing from the input parameter.
#The function missing_letters should combine the list of missing letters into a string and return that string.
def missing_letters(sTr):
missingLettersList = []
dic = histogram(sTr)
for l in alphabet:
if l not in dic:
missingLettersList.append(l)
missingLettersList.sort()
return "".join(missingLettersList)
#Write a loop over the strings in list test_miss and call missing_letters with each string. Print a line for each string listing the missing letters.
#For example, for the string "aaa", the output should be the following. aaa is missing letters bcdefghijklmnopqrstuvwxyz
#If the string has all the letters in alphabet, the output should say it uses all the letters.
#For example, the output for the string alphabet itself would be the following. abcdefghijklmnopqrstuvwxyz uses all the letters
#Print a line like one of the above for each of the strings in test_miss.
print("\n***Implementation of missing_letters fuction***")
for lTm in test_miss:
sTr = missing_letters(lTm.replace(" ",""))
if sTr!="":
print(lTm+" is missing letters "+sTr)
else:
print(lTm +" uses all the letters")
Lily is in her first year of undergraduate coursework and has not yet declared a major. She has attended a lot of career fairs and undergraduate major "open house" events to investigate her options. Marcia's theory of identity status suggests that the dimension Lily is most concerned with is the_____of 1 dimension.
Answer:
exploration
Explanation:
According to Marcia's theory of identity, the status suggests that the dimension Lily is most concerned with is the exploration dimension.
James E. Marcia who came up with the Marcia's theory of identity is a clinical and developmental psychologist. He also once taught at Simon Fraser University which is located in British Columbia, Canada and also in the State University of New York at Buffalo in Upstate, New York City.
James E. Marcia is also very much involved in clinical private practice, community consultation, clinical psychology supervision, and also in international clinical-developmental research and teaching.
If distances are recorded as 4-bit numbers in a 500-router network, and distance vectors are exchanged 3 times/second, how much total bandwidth (in bps) is used by the distributed routing algorithm
Answer:
A total of 6,000 bps of bandwidth is used by the distributed routing algorithm
Explanation:
This is a bandwidth requirement question.
We proceed as follows;
To calculate the total number of bits for a routing table, we use the following formula;
Routing table=Number of routers * length of cost
we are given the following parameters from the question;
Number of routers = 500
length of cost = 4 bits
Routing table = 500*4
=2000
Hence, a routing table is 2000 bits in length.
Now we proceed to calculate the bandwidth required on each line using the formula below;
Bandwidth = no.of seconds * no.of bits in routing table
Bandwidth required on each line = 3*2000
=6000
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
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.