Answer:
a.
Explanation:
Two bytes have 2 times 8 bits is 16 bits.
Max value that can be expressed is 2¹⁶-1 = 65535
A user states that when they power on their computer, they receive a "Non-bootable drive" error. The user works with external storage devices to transport data to their computer. The user stated that the computer worked fine the day before. Which of the following should be checked FIRST to resolve this issue?
A. Jumper settings
B. Device boot order
C. PXE boot settings
D. Hard drive cable
Answer:
B. Device boot order
Explanation:
The Device boot order makes a list of all the possible devices a system should check to in the operating system's boot files, as well as the proper sequence they should be in. Removable devices, hard drives, and flash drives are some devices that can be listed in the device boot order.
For the user whose computer displays a 'non-bootable drive' error, the device boot order would check all the devices listed to attempt booting from any of them. These devices might be in the order of removable discs, CD-ROM, hard drive. If all the options do not work, the computer would then do a Network boot. The order in which the devices are listed can be altered by the user.
Describe in detail how TCP packets flow in the case of TCP handoff, along with the information on source and destination addresses in the various headers.
Answer:
Following are the answer to this question:
Explanation:
There will be several ways to provide it, although it is simpler to let another front side Will work out a three-way handshake or transfer packages to there with a Server chosen. Its application responds TCP packets with both the destination node of the front end.
The very first packet was sent to a computer as an option. Mention, even so, that perhaps the end of the queue end remains in the loop in this scenario. Rather than obtaining this information from the front end like in the primary healthcare services, you have the advantage of this capability: its selected server helps to generate TCP state.
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
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.
Write a program that extracts the last three items in the list sports and assigns it to the variable last. Make sure to write your code so that it works no matter how many items are in the list
Answer:
sports = ["football", "basketball", "volleyball", "baseball", "swimming"]
last = sports[-3:]
print(last)
Explanation:
*The code is in Python.
Create a list called sports
Create a variable called last and set it to the last three elements of the sports list using slicing
Print the last
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.
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.
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.
What is displayed in the alert dialog box after the following code is executed? var scores = [70, 20, 35, 15]; scores[scores.length] = 40; alert("The scores array: " + scores);
Answer:
The scores array: 70,20,35,15,40
Explanation:
I will explain the code line by line:
var scores = [70, 20, 35, 15];
The above statement declares and assigns values to an array named scores
scores[scores.length] = 40;
The above statement uses length to set the length of the scores array. It sets the last element of the scores array to 40. So this means 40 is set as the last element of scores.
scores.length returns the length of the scores array i.e. 4 as there are 4 elements in scores array 70,20,35,15
So the statement becomes:
scores[4] = 40;
This assigns value 40 to the 4th index of the scores array. Do not confuse 4th index with 4th element of the array because array element location starts from 0. So scores[4] does not mean 4th element but scores[4] means 4th index position of scores array. This makes 5th element of scores. So set the element 40 as 5th element at 4th index of scores.
alert("The scores array: " + scores);
This displays an alert box with the following message:
The scores array: 70,20,35,15,40
Modularize the program by adding the following 4 functions. None of them have any parameters. void displayMenu() void findSquareArea() void findCircleArea() void findTriangleArea() To do that you will need to carry out the following steps: Write prototypes for the four functions and place them above main. Write function definitions (consisting of a function header and initially empty body) for the four functions and place them below main. Move the appropriate code out of main and into the body of each function. Move variable definitions in main for variables no longer in main to whatever functions now use those variables. They will be local variables in those functions. For example, findSquareArea will need to define the side variable and findCircleArea will need to define the radius variable. All of the functions that compute areas will now need to define a variable named area. Move the definition for the named constant PI out of main and place it above the main function. In main, replace each block of removed code with a function call to the function now containing that block of code.
Answer:
It is a C++ program :
#include <iostream> // to use input output functions
using namespace std; //to identify objects like cin cout
//following are the prototypes for the four functions placed above main
void displayMenu();
void findSquareArea();
void findCircleArea();
void findTriangleArea();
//definition for constant PI out of main
const float PI = 3.14159;
int main(){ //start of main function
displayMenu(); //calls displayMenu() method
}
void displayMenu(){ // to make user selection and calls relevant function to compute area according to the choice of user
int selection=0; //to choose from 4 options
cout<<"Program to calculate areas of objects:\n" ; //displays this message at start
do { //this loop asks user to enter a choice and this continues to execute and calculate depending on users choice until user enters 4 to exit
cout<<"\n1.Square \n2.Circle \n3.Right Triangle \n4.Quit";
cout<<"\nEnter your choice:"; //prompts user to enter choice
cin>>selection; //reads the input choice
if(selection==1) //if user enters 1
{ //computes area of square by calling findSquareArea
findSquareArea(); //function call to the findSquareArea function
}
else if(selection==2) //if user enters 2
{ //computes area of circle by calling findCircleArea
findCircleArea(); //function call to the findCircleArea function
}
else if(selection==3) //if user enters 3
{ //computes area of triangle by calling findTriangleArea
findTriangleArea(); //function call to the findTriangleArea function
}
else if(selection==4) //if user enters 4
{
cout<<"\nTerminating!!."; //exits after displaying this message
break;
}
else // displays the following message if user enters anything other than the given choices
{
cout<<"\nInvalid selection"; //displays this message
}
}
while(1);
}
void findSquareArea(){ //function definition. this function has no parameters
float area=0.0; //variable to store the area of square
float side=0; //local variable of this method that stores value of side of square
cout<<"\nLength of side: "; //prompts user to enter length of side
cin>>side; //reads value of side from user
area=side*side; //formula to compute area of square and result is assigned to area variable
cout<<"\nArea of Square: "<<area<<endl; //displays are of the square
}
void findCircleArea(){ //function definition. this function has no parameters
float area=0.0; //variable to store the area of square
float radius=0.0; //local variable of this method that stores value of radius of circle
cout<<"\nRadius of circle: "; //prompts user to enter radius of circle
cin>>radius; // reads input value of radius
area=PI*radius*radius; //formula to compute area of circle
cout<<"\nArea of circle: "<<area<<endl;} //displays are of the circle
void findTriangleArea(){ //function definition. this function has no parameters
float area=0.0; //variable to store the area of triangle
float base=0.0; //local variable of this method that stores value of base of triangle
float height=0.0; //holds value of height of triangle
cout<<"\nHeight of Triangle: "; //prompts user to enter height
cin>>height; //reads input value of height
cout<<"\nBase of Triangle: "; //prompts user to enter base
cin>>base; //reads input value of base
area=0.5*height*base; //computes area of triangle and assign the result to area variable
cout<<"\nArea of Triangle: "<<area<<endl; //displays area of triangle
}
Explanation:
The program is modified as above. The prototypes for the four functions that are named as :
void displayMenu(); to display the Menu of choices and call relevant function to compute area
void findSquareArea(); To compute area of square
void findCircleArea(); To compute area of circle
void findTriangleArea(); To compute area of triangle
Note that these methods have no parameters and their return type is void. These 4 methods prototypes are placed above main() function.
Next the function definitions (consisting of a function header and initially empty body) for the four functions are written and placed below main() For example definition of findTriangleArea() is given below:
void findTriangleArea()
{
}
Next the code in the main is moved to the relevant methods. Then variables selection=0; is moved to displayMenu method, radius=0.0 to findCircleArea method , side=0; to findSquareArea float area=0.0; to each method, float height=0.0; and float base=0.0; to findTriangleArea method.
The relevant code moved to each method is shown in the above code.
The definition for the named constant PI is moved out of main and placed above the main function. const keyword before datatype of PI variable shows that PI is declared constant and its value is initialized once only to 3.14159.
Class or Variable "____________" serve as a model for a family of classes or variables in functions` definitions
Answer:
Parameter.
Explanation:
A parameter variable stores information which is passed from the location of the method call directly to the method that is called by the program.
Class or Variable parameter serve as a model for a family of classes or variables in functions' definitions.
For instance, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function.
Hence, when you create classes or variables in a function, you can can set the values for their parameters.
For instance, to pass a class to a family of classes use the code;
\\parameter Name as Type (Keywords) = value;
\\procedure XorSwap (var a,b :integer) = "myvalue";
Imagine you have a 10-character string stored in the variable myString. You want to pull out the first five characters. Which of the following lines of code would successfully generate a slice of the 10-character string holding only the first five characters?
a. myString[5]
b. myString[:-5]
c. myString[0:6]
d. myString-15:-5]
e. myString[0:10:2]
Answer:
b. myString[:-5]
d. myString[-15:-5]
Explanation:
I believe you have a typo in d. It must be d. myString[-15:-5]
Slicing can be done:
myString[starting_index, stopping_index, step] (step is optional). If you do not specify the starting index, it will start from the 0 as in b. If you write a range that is not in the range, as in d, Python will replace it with either 0 or length of the string (In this case, it is replaced with 0 because the starting index must be smaller than stopping index)
a. myString[5] → This will give you the sixth character
b. myString[:-5] → This will give you the first five characters
c. myString[0:6] → This will give you the first six characters
d. myString-15:-5] → This will give you the first five characters
e. myString[0:10:2] → This will give you the first, third, fifth, seventh, and ninth characters
Which statement is false?Structures are derived data types.Each structure definition must end with a semicolon.A structure can contain an instance of itself.Structures may not be compared using operators == and !=.
Answer:
A structure can contain an instance of itself
Explanation:
The statement which is known to be false out of the option given is that a structure may comprise or contain an instance of itself. Because to my knowledge, variables of diverse type are always most likely to attributed and contain by a structure.
It is worthy of note that object that aren't similar are utilize in constructing a structure. Another true statement about structure is that a semicolon usually end it's explanation.
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
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 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
Some systems analysts maintain that source documents are unnecessary. They say that an input can be entered directly into the system, without wasting time in an intermediate step.
Do you agree? Can you think of any situations where source documents are essential?
Answer:
The summary including its given subject is mentioned in the portion here below explanatory.
Explanation:
No, I disagree with the argument made by 'system analyst' whether it is needless to preserve source records, rather, therefore, the details provided input would be fed immediately into the machine. Different source document possibilities can be considered may play a significant role in accessing data.Assumed a person experiences a problem when collecting and analyzing data that has no complete access or that individual is not happy with the system or that may want comprehensive data search. However, a need arises to keep data both sequentially and fed further into the desktop system that would help us through tracking purposes.Even with all the documentation that has been held is essentially for the user to do anything efficiently and conveniently without even any issues and 'device analyst' would guarantee that it has been applied in a very well-defined way.Write a function named twoWordsV2 that has the same specification as Problem 1, but implement it using while and not using break. (Hint: provide a different boolean condition for while.) Since only the implementation has changed, and not the specification, for a given input the output should be identical to the output in Problem 1.
Answer:
I am writing a Python program. Here is the function twoWordsV2:
def twoWordsV2 (length,firstLetter):#definition of function which takes length of the first word and first letter of the second word as parameter and returns these two words in a list
word1 = "" # stores the first word
word2= "" #holds the second word
while(len(word1)!=length): # checks if the input word1 length is not equal to the specified length
word1 = input('A ' + str(length) + '-letter word please: ') #asks user to enter the input word1 of specified length
while(word2!=firstLetter): #checks if the first character of input word2 is not equal to the specified firstLetter character
word2 = input('A word beginning with ' + firstLetter+ ' please: ')#asks user to enter the input word2 begining with specified first letter
if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower():#second word may begin with either an upper or lower case instance of firstLetter
return [word1,word2] #return the two words in a list
#to check the working of the function use the following statement
print(twoWordsV2(4,'B')) #calls twoWordsV2 method by passing 4 (length) and B (first letter)
Explanation:
twoWordsV2 method has two parameters i.e length which is the length of the first word and firstLetter which is the first character of the the second word. This means the first word should be of specified length, and the second word should begin with a specified first letter. The function returns the two resultant words with the above specifications. These two words are displayed in a list. I will explain the working of the function with the help of an example:
Suppose length = 4 and firstLetter = 'B' and user enters "ok" as word1. input() method takes first word input from user.
The first while loop checks if the length of word1 i.e. ok is not equal to specified length i.e. 4. Length of word1 is checked using len function which returns 2 so length of word1 is 2. The loop condition is true because length of word1 i.e. 2 is not equal to specified length i.e. 4. So the body of the loop executes which displays this message:
A 4-letter word please:
Here notice that str(length) is changed to 4. This is because length=4 and str() converts this value into string.
So the above message keeps displaying until user enters a four letter word. Lets suppose user now enters "four". Now the while loop condition evaluates to false and the loop breaks. The program control moves to the next line which is a while loop.
The second while loop checks if the first character of input word2 is not equal to the specified firstLetter character. Suppose word2 = "apple" and firstLetter= 'B'
Now the loop condition evaluates to true because word2 is not equal to first letter B. Now the main part of this while loop is the if condition: if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower() This statement checks if the first index of the word2 is equal to firstLetter. The word2 can contain a capital B or a small B so if condition checks both the cases by using upper and lower methods that converts the firstLetter to upper or lower and then match with the first letter of word2 i.e. the letter at index 0 of the word2. If this condition evaluates to true then next return statement returns the word1 and word2 in a list otherwise the second while loop keep asking user to enter the word2 with starting letter to be firstLetter i.e. 'B'.
The screenshot of the program and its output is attached.
The function for the given problem is:
def twoWordsV2 (length,firstLetter):word1 = "" # stores the first wordword2= "" #holds the second word while(len(word1)!=length): word1 = input('A ' + str(length) + '-letter word please: ') while(word2!=firstLetter): word2 = input('A word beginning with ' + firstLetter+ ' please: ')if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower(): return [word1,word2] print(twoWordsV2(4,'B')) Brief Explanation:These 10 lines of code were written using the Python programming language and this was used to define, store and hold the function and then request input from the user, check if the given input was according to the required parameters, and then print the output.
Read more about python programming language here:
https://brainly.com/question/7015522
When you create a .wim file instead of a .vhdx file, how is the .wim file used to deploy the Nano Server
Answer:
the server will atomaticly detect
Explanation:
not worry
Kaiden would like to find the list of physical disk drives that are connected to a Linux system. Which directory contains a subdirectory for each drive
Answer:
The answer is "\root"
Explanation:
The root directory is the part of the Linux OS directory, which includes most other system files and folders but is specified by a forward slash (/). These directories are the hierarchy, which is used to organize files and folders on a device in a standardized protocol framework. This root is also known as the top directory because it .supplied by the os and also is designated especially, that's why it is simply called root.____ enable users to create and edit collaborative Web pages quickly and easily; they are intended to be modified by others and are especially appropriate for collaboration.
Answer:
Wikis
Explanation:
Wikis can be defined as a database that was designed by users which gives users the opportunity to add, edit and delete collaborative web pages easily.
It lets users to manage contents easily and they are used to create static websites.
some wikis can be accessed by the public. A great example is Wikipedia.
Wikis allows publishing and sharing of documents to be done easily.
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.
Draw the BST where the data value at each node is an integer and the values are entered in the following order 36,22,10,44,42,16,25,3,23,24 solution
Answer and Explanation:
A BST is the short form for Binary Search Tree. It is a special type of binary tree data structure in which nodes are arranged in a particular order such that;
i. the left subtree of a particular node should always contain nodes whose key values are less than that of the key value of the node itself.
ii. the right subtree of a particular node should always contain nodes whose key values are greater than that of the key value of the node itself.
iii. the right and left subtrees should also be a binary search tree.
For the given set of data:
36,22,10,44,42,16,25,3,23,24;
The equivalent binary search tree is attached to this response.
As shown in the attachment:
i. the first data value (36) is the root node value.
ii. the second value (22) is less than the root node value (36), therefore, 22 goes to the left of the root node.
iii. the third value is 10. This is less than 36 and then also less than 22, so 10 goes to the left of 22.
iv. the fourth value is 44. This is greater than the root node value (36), therefore, 44 goes to the right of the root node.
v. the fifth value is 42. This is greater than the root value (36) so it is going to be positioned somewhere at the right of the root node. But it is less than the value (44) of the direct right node of the root node. Therefore, 42 goes to the left of the direct right (44) of the root node.
vi. the sixth value is 16. This is less than the root node value (36). So it is going to be positioned somewhere at the left of the root node. It is also less than the value (22) of the direct left node of the root node. So it is going to be positioned somewhere at the left of the node with 22. But it is greater than the node with 10. Therefore, 16 is going to be to the right of the node with 10.
This trend continues until all data values have been rightly positioned.
PS: A binary tree is a data structure in which each node cannot have more than two nodes directly attached to it.
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
The conversion of symbolic op codes such as LOAD, ADD, and SUBTRACT to binary makes use of a structure called the ____.
Answer:
Op code table.
Explanation:
In Computer programming, an Op code is the short term for operational code and it is the single instruction which can be executed by the central processing unit (CPU) of a computer.
The conversion of symbolic op codes such as LOAD, ADD, and SUBTRACT to binary makes use of a structure called the Op code table. The Op code can be defined as a visual representation of the entire operational codes contained in a set of executable instructions.
An Op code table is arranged in rows and columns which basically represents an upper or lower nibble and when combined depicts the full byte of the operational code. Each cells in the Op code table are labeled from 0-F for the rows and columns; when combined it forms values ranging from 00-FF which contains information about CPU cycle counts and instruction code parameters.
Hence, if the operational code table is created and sorted alphabetically, the binary search algorithm can be used to find an operational code to be executed by the central processing unit (CPU).
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 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.
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.
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.
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.