buffer-overflow attacks can be avoided by adopting a better programming methodology or by using special hardware support. discuss these solutions.

Answers

Answer 1

Preventing the execution of code that is found in the stack segment of a process's location space is one sort of hardware support that makes sure that a buffer overflow attack doesn't take place.

Buffer-overflow: What is it?

When an application tries to store more data in the buffer memory than the memory can hold, the result is a condition known as buffer overflow, also referred to as buffer overrun. This causes data to be stored onto adjacent storage, where it may occasionally overwrite the current data, potentially resulting in data loss and occasionally even a system crash.

Which programming languages are most susceptible to attacks involving buffer overflows?

The vulnerability of a buffer overflow software written in Assembly, C, C++, or Fortran makes it more possible for attackers to exploit a system. However, JavaScript or Perl-written apps are often less susceptible to buffer overflow attacks.

To learn more about buffer-overflow visit:

brainly.com/question/14369388

#SPJ4


Related Questions

Windows Network Diagnostics, a GUI tool included with Windows 7 and Windows 8.x, will diagnose a network problem and instruct you on how to solve the problem. True or False

Answers

A GUI application called Windows Network Diagnostics that comes with Windows 7 and Windows 8.x will diagnose a network issue and provide you instructions on how to fix it. The assertion is accurate.

What is the purpose of GUI?

Choice points will be shown to the user that are easy to spot, understand, and utilize. In other words, GUI makes it possible for you to control your device using a mouse, a pen, or even your finger. GUI was created because text command-line interfaces were convoluted and difficult to comprehend.

What GUI examples are there?

Computer monitors, mobile devices like smartphones and tablets, and gaming consoles are a few examples of GUIs. The software on the gadget continuously scans the screen to ascertain where and how the pointing devices are moving.

To know more about GUI tool visit:

https://brainly.com/question/10729185

#SPJ4

create a logical model identify entities and attributes input the data into the tables database create a conceptual model implement the database

Answers

A logical model includes depictions of entities, properties, relationships, special identifiers, sub types, and super types, as well as restrictions on how relationships can be formed.

What is  data model?

A logical model may also reference one or more domain or glossary models or include objects from a domain model. Relational data models, network data models, and hierarchical data models are three examples of this sort of data model. Data are represented as relations, or tables, in the relational model. System for managing orders simply. This is a conceptual data model for a straightforward wholesale retail order management system. Even though some consumers might not have sent any orders yet, customers send orders to the store. Each order item for a product is one of many order items that make up the order.

To learn more about  data model from given link

brainly.com/question/10686043

#SPJ4

eigrp authentication ensures that routers only accept routing information from other routers that have been configured with the same password or authentication information

Answers

EIGRP supports MD5 for authentication. When enabled, routers verify the origin of each packet containing a routing update.

Why is it important to configure authentication with EIGRP?

It's critical to keep in mind that this system is only for authentication. The routing update packets are not encrypted by the routers before they are sent via the network. These packets are simply authenticated using MD5. This stops users from deliberately or unintentionally inserting routes into your network.

EIGRP supports MD5 for authentication. When enabled, routers verify the origin of each packet containing a routing update. False EIGRP adjacency cannot be established by an attacker thanks to the following settings. The result of bogus adjacency may be poisoning of the routing table or CPU overuse.

To learn more about EIGRP  visit:https://brainly.com/question/29038683

#SPJ4

Recall that a contiguous subarray is all of the elements in an array between indices
i
and
j
, inclusive (and if
j we define it to be the empty array). Call a subarray is nearly contiguous if it is contiguous (i.e. contains all elements between indices
i
and
j
for some
i,j
) or if it contains all but one of the elements between
i
and
j
. For example, in the array
[0,1,2,3,4]
, -
[0,2,3]
is nearly contiguous (from 0 to 3 , skipping 1 ), sum is 5 -
[0,1,2,3]
is nearly contiguous (because it is contiguous from 0 to 3 ), sum is 6 . -
[2,4]
is nearly contiguous (from 2 to 4 , skipping 3 ), sum is 6 . - [3] is nearly contiguous (because it is contiguous from 3 to 3 ), sum is 3 . - [] is nearly contiguous (because it is contiguous from 1 to 0 ), sum is 0 . -
[0,2,4]
is not nearly contiguous (because you'd have to remove two elements). The sum of a nearly contiguous subarray is the sum of the included elements. Given int [] A, your task is to return the maximum sum of a nearly contiguous subarray. For example, on input
[10,9,−3,4,−100,−20,15,−5,9]
your algorithm should return 24 (corresponding to
i=
6,j=8
and skipping the
−5
). (a) Define one or more recurrences to solve this problem. (b) Give English descriptions (1-2 sentences each should suffice) for what your recurrences calculate. Be sure to mention what any parameter(s) mean. (c) How do you caclulate your final overall answer (e.g. what parameters input to which of your recurrences do you check). (d) What memoization structure(s) would you use? (e) What would the running time of your algorithm be (you do not have to write the code). Justify in 1-3 sentences.

Answers

(a) One possible recurrence to solve this problem is:

Let f(i, j) be the maximum sum of a nearly contiguous subarray ending at index j and starting at index i or before.

Then the recurrence can be written as:

f(i, j) = max(f(i, j-1), f(i, j-2) + A[j])

This recurrence calculates the maximum sum of a nearly contiguous subarray ending at index j and starting at index i or before by considering two possibilities:

The subarray does not include the element at index j. In this case, the maximum sum is the same as the maximum sum ending at index j-1.

The subarray includes the element at index j, but skips the element at index j-1. In this case, the maximum sum is the sum of the elements ending at index j-2 plus the element at index j.

(b) Another possible recurrence to solve this problem is:

Let g(i, j) be the maximum sum of a contiguous subarray ending at index j and starting at index i or before.

Then the recurrence can be written as:

g(i, j) = max(g(i, j-1) + A[j], A[j])

This recurrence calculates the maximum sum of a contiguous subarray ending at index j and starting at index i or before by considering two possibilities:

The maximum sum of the subarray includes the element at index j. In this case, the maximum sum is the sum of the maximum sum ending at index j-1 plus the element at index j.

The maximum sum of the subarray does not include the element at index j. In this case, the maximum sum is simply the element at index j.

(c) To calculate the final overall answer, we can input the values 0 and n-1 into both recurrences, where n is the length of the array A. This will give us the maximum sum of a nearly contiguous subarray that starts at the beginning of the array and ends at the end of the array.

(d) To implement these recurrences using memoization, we can use a two-dimensional array to store the calculated values of f and g. The array can be initialized with values of 0 for all indices, and then we can fill in the values starting from the bottom right corner and working our way towards the top left corner.

(e) The running time of this algorithm would be O(n^2), because we need to calculate the values of f and g for every possible pair of indices i and j. This requires O(n^2) time in the worst case.

Listen The principle of limiting users' access to only the specific information required to perform their assigned tasks. 1) Blueprint 2) Framework 3) Least privilege 4) Need-to-know 5) Security model Question 3 (1 point)

Answers

Least privilege is the principle of limiting users' access to only the specific information required to perform their assigned tasks.

What is a leat privilege?The idea that a security architecture should be built so that every entity is given the minimal system resources and authorizations necessary for them to carry out their function.Information security is a complicated, diverse discipline that is based on numerous fundamental ideas. Any information security programme should aim to achieve the three most crucial ones: confidentiality, integrity, and availability (also known as the CIA triad).The cyberattack surface is smaller as a result.Least privilege enforcement contributes to lowering the overall cyber attack surface by reducing super-user and administrator privileges (which provide IT administrators unrestricted access to target systems).The two terms' purviews differ, and this is why: The idea of least privilege also applies to non-human users such as system accounts, programmes, services, and devices, whereas need-to-know only considers how many people can read a given piece of information.

To know more about leat privilege refer to:

https://brainly.com/question/29793574

#SPJ4

Zach believes someone is trying to log in to a computer system in order to gain access to the company's network. He wants to use Windows to determine if that is the case.Where can Zach go to check the security logs?a. Event Viewer

Answers

One of your computer's most underused features is definitely Event Viewer, and it surprises me how few even competent experts use this straight forward tool to provide such straightforward answers. Event Viewer is tricky since you have to set it up correctly.

What kind of software does a computer utilize to be controlled?

A computer's operating system is a piece of software that manages and organizes the hardware components as well as runs other programs and applications. It is the primary component of the system software, and a computer cannot operate without it.

What three categories of system software exist?

Application programs, device drivers, and operating systems are the three main categories of software that make up your system.

To know more about Event Viewer visit :-

https://brainly.com/question/14166392

#SPJ1

assuming a 1-kb page size, what are the page numbers and offsets for the following address references (provided as decimal numbers)? (a) 21205 (b) 164250 (c) 121357 (d) 16479315 (e) 27253187

Answers

Note that the Page numbers and offsets for the following address references given a 1-kb page size are:

a) Address: 21205 → Page number: 20, Offset: 905

b) Address: 164250 → Page number: 161, Offset: 202

c) Address: 121357 → Page number: 119, Offset: 333

d) Address: 16479315 → Page number: 16093, Offset: 659

e) Address: 27253187 → Page number: 26708, Offset: 963.

What is an offset and an address reference?

Note that an offset is a numerical value that represents the distance of a particular location within a file, block of memory, or other data structure from a reference point. It is often used to specify the location of a particular piece of data within a larger structure.

An address reference is a value that represents the location of a specific piece of data within a computer's memory.

To determine the page numbers and offsets for the given address references, you will need to divide the address by the page size. The page number will be the result of the division, and the offset will be the remainder.

Thus, for a:
Address: 21205 → Page number: 21205 / 1024 = 20,

Offset: 21205 % 1024 = 905

for b,
Address: 164250 → Page number: 164250 / 1024 = 161, Offset: 164250 % 1024 = 202


for c,
Address: 121357 → Page number: 121357 / 1024 = 119,

Offset: 121357 % 1024 = 333

for d,

Address: 16479315 => Page number: 16479315 / 1024 = 16093,

Offset: 16479315 % 1024 = 659

for e,

Address: 27253187 => Page number: 27253187 / 1024 = 26708,

Offset: 27253187 % 1024 = 963

In conclusion,

a) Address: 21205 → Page number: 20, Offset: 905

b) Address: 164250 → Page number: 161, Offset: 202

c) Address: 121357 → Page number: 119, Offset: 333

d) Address: 16479315 → Page number: 16093, Offset: 659

e) Address: 27253187 → Page number: 26708, Offset: 963.

Learn more about Address References:
https://brainly.com/question/2342795
#SPJ1

Determine all cache accesses and the state of the data cache at any given time. From this you can determine any additional cycles from data cache misses. You must calculate the number of bits for the offset, index, and tag, determine the number of hits and misses, show the contents of the cache, and use the number of misses to determine any additional clock cycles required. The total clock cycles would be the total cycles for all iterations from Part 2 plus any additional memory access cycles from cache misses from Part 3.

Answers

The smallest and fastest part of a computer system's memory is the cache. The registers, which make up a very minor portion of the computer CPU, are quick storage components.

Why does the cache memory access time take less time than the main memory access time?

Cache memory must be substantially smaller than main memory in order to be situated near to the CPU. As a result, it has less room for storage. Due to the increased performance of the more complicated chip, it is also more expensive than main memory.

What distinguishes Level 1 from Level 2 and Level 3 cache benefits?

Since it is the smallest and nearest to the CPU, Level 1 (L1) cache memory is the quickest type. On the processor chip, Level 2 (L2) has a larger capacity but a slower speed. The computer that uses the L2 cache has the biggest capacity Level 3 (L3) cache memory.

To know more about Cache memory visit:-

https://brainly.com/question/16091648

#SPJ4

(T/F) Desktop Management software requires managers to install software such as antivirus updates or application updates on client computers manually.

Answers

Managers must manually install software, such as antivirus updates or application updates, on client computers when using desktop management software. The answer is False.

What is Desktop Management software?

All computer systems inside a company are managed and secured by a desktop management programme, which is a complete tool. The management of other devices used by the organization, such as laptops and other computer devices, is also a part of "desktop" administration, despite the name.

Without requiring physical access to the endpoints, such as desktop computers or mobile devices, desktop management software enables IT teams to locate, manage, and control endpoints on both local and remote sites.

Keeping user PCs up to date can be difficult for IT managers, especially with the ongoing need to upgrade software to prevent security breaches.

To know more about Desktop Management software refer to :

brainly.com/question/13051262

#SPJ4

When investigating a Windows System, it is important to view the contents of the page or swap file because:PrepAway - Latest Free Exam Questions & AnswersA.Windows stores all of the systems configuration information in this fileB.This is file that windows use to communicate directly with RegistryC.A Large volume of data can exist within the swap file of which the computer user has no knowledgeD.This is the file that windows use to store the history of the last 100 commands that were run from the command line

Answers

When investigating a Windows System, it is important to view the contents of the page or swap file because a large volume of data can exist within the swap file of which the computer user has no knowledge.

What is swap file in a windows system?

When the system's memory is low, a swap file is a system file that generates temporary storage space on a solid-state drive or hard disk. The file frees up memory for other programs by swapping a portion of RAM storage from an inactive program.

The computer can use more RAM than is actually installed by employing a swap file. In other words, it can run more applications than it could with just the installed RAM's constrained resources.

Swap files are a form of virtual memory because they are not kept in actual RAM. A computer's operating system (OS) can seem to have more RAM than it actually does by using a swap file.

To know more about swap file refer:

https://brainly.com/question/9759643

#SPJ4

________ hackers are security experts that are paid to hack systems to find security holes for the purpose of preventing future hacking.
O Black-hat
O Gray-hat
O Red-hat
O White-hatAnswer: White-hat

Answers

White hat hackers are salaried workers or independent contractors who act as security experts for businesses and use hacking to try and uncover security flaws.

What kind of hackers get into systems for fun or to demonstrate their prowess?

Black hat hackers, often known as crackers, are dishonest hackers. Black hats are unethical, occasionally break the law, break into computer systems with malicious intent, and may compromise the privacy, integrity, or accessibility of a company's systems and data.

A Red hat hacker is a who?

Targeting Linux systems could be referred to as being a red hat hacker. Red hats, however, have been compared to vigilantes. Red hats aim to disarm black hats much like white hats do, although their strategies diverge greatly from those of the former.

To know more about hackers visit:-

https://brainly.com/question/29215738

#SPJ4

T F a) Void Functions can use reference parameters.

Answers

Function Calls Using Value and Reference Parameter Examples: Void function call using value parameters (can use expression, constant, or variable)

What is void function in C programming?

Except that they do not return a value when the function executes, void functions are constructed and used just like value-returning functions. The term "void" is used by void functions in place of a data type. A void function does a job before returning control to the caller; nevertheless, it does not return a value.Statements that are void functions are independent. When the function return type in computer programming is void, it means the function doesn't return a value. The word void indicates that a pointer is universal when it appears in a pointer declaration.A function called void *function() in the C programming language returns a value that, when dereferenced, is of the type void.

Learn more about void function refer to :

https://brainly.com/question/25644365

#SPJ4

Is it possible in Swift to group case matches together with a common set of statements to be executed when a match for any of the cases is found. For example, is the following allowed?
case 3, 5, 7:
// code for case
A. Yes
B. No

Answers

Answer:

A. Yes, it is possible in Swift to group case matches together with a common set of statements to be executed when a match for any of the cases is found.

Explanation:

To group case matches together, you can use a comma-separated list of patterns after the keyword "case", as shown in your example. When a match is found for any of the cases in the list, the code block following the "case" statement will be executed.

Here is an example of how you could use this feature in a switch statement in Swift:

let x = 3

switch x {

case 3, 5, 7:

   print("x is 3, 5, or 7")

default:

   print("x is not 3, 5, or 7")

}

after roughly how many seconds does the amount of information in immediate memory begin to drop off precipitously? type your numeric answer and submit numeric answer - type your numeric answer and submit

Answers

After 3 seconds the amount of information in immediate memory begins to drop off precipitously.

What exactly do you mean by instant memory?

a sort or stage of memory when a person can recall details that were recently presented, like a street address or phone number, even though those details might be forgotten after being used right away. A common test to determine IQ or neurological damage is the immediate memory test.

What purposes serve IQ tests?

A person's short-term and long-term memory is measured as the first step of an IQ test to determine their level of intelligence. It evaluates how quickly people can do these tasks as well as how effectively they can solve puzzles or recall information they have heard.

To know more about IQ visit:

https://brainly.com/question/29035691

#SPJ4

transmission often is called fixed wireless. group of answer choices microwave infrared coax fiber-optic

Answers

Signals are sent from one microwave station to another during microwave transmission, also known as fixed wireless (shown in Figure 8-1 on page 296). A dial-up modem cannot send data as quickly as a microwave, which can do it up to 4,500 times quicker.

Which alternative name for transmission data is appropriate?

It makes it possible for devices to move between and communicate with one another in point-to-point, point-to-multipoint, and multipoint-to-multipoint environments. Digital communications and transmission of data are other names for these processes.

Is fiber-optic fixed-wireless?

Internet access using fixed wireless is frequently used in rural areas and other places without fiber-optic infrastructure. Although portable and mobile systems can be employed in fixed sites, their efficiency and bandwidth are limited in comparison to stationary systems.

To know more about fixed wireless visit;

https://brainly.com/question/13010901

#SPJ4

the parallelism of a multithreaded computation is the maximum possible speedup that can be achieved on any number of processors

Answers

The greatest speedup that any number of processors may achieve is the parallelism T1/T8. For any number of processors more than the parallelism T1/T8, perfect linear speedup cannot be achieved.

What does a computation that uses several threads do?

The overall amount of time needed to complete a multithreaded computation on a single processor is called the work. Therefore, the work is an accounting of the total time spent on each thread.

What does a parallel computer accomplish?

The total quantity of computing effort that is completed is referred to as work in physics. With P processors, an ideal parallel computer can complete up to P units of work in one time step.

To know more Parallelism T1/T8 visit :-

https://brainly.com/question/29190324

#SPJ4

to mitigate network attacks, you must first secure devices including routers, switches, servers, and supervisors.

Answers

Yes, securing devices is an important step in mitigating network attacks.

Yes, securing devices is an important step in mitigating network attacks.

What are some general recommendations for securing devices?Keep software up to date: Make sure to install the latest software updates and security patches for all devices.Use strong passwords: Use unique, complex passwords for all devices and change them regularly.Enable security features: Use security features like firewalls, encryption, and authentication to help protect devices from attacks.Monitor and maintain devices: Regularly monitor the security of your devices and maintain them in good working order to help prevent attacks.Limit access: Only allow authorized users to access your network and devices, and limit their access to only the resources they need to do their job.Use network segmentation: Divide your network into smaller segments to make it harder for attackers to gain access to sensitive areas.Use network access controls: Implement network access controls to allow or block devices from connecting to your network based on predefined rules.

To Know More About firewalls, Check Out

https://brainly.com/question/13098598

#SPJ4

Sprint Review and Retrospective
As would normally happen at the end of a Sprint or an incremental release, the Scrum Master will put together a Sprint Review and Retrospective. For this deliverable, you will take on the role of the Scrum Master and create a Sprint Review and Retrospective to summarize, analyze, and draw conclusions on the work you completed during the course of the development. In a paper, be sure to address each of the following:Demonstrate how the various roles on your Scrum-agile Team specifically contributed to the success of the SNHU Travel project. Be sure to use specific examples from your experiences.
Describe how a Scrum-agile approach to the SDLC helped each of the user stories come to completion. Be sure to use specific examples from your experiences.
Describe how a Scrum-agile approach supported project completion when the project was interrupted and changed direction. Be sure to use specific examples from your experiences.
Demonstrate your ability to communicate effectively with your team by providing samples of your communication. Be sure to explain why your examples were effective in their context and how they encouraged collaboration among team members.
Evaluate the organizational tools and Scrum-agile principles that helped your team be successful. Be sure to reference the Scrum events in relation to the effectiveness of the tools.
Assess the effectiveness of the Scrum-agile approach for the SNHU Travel project. Be sure to address each of the following:
Describe the pros and cons that the Scrum-agile approach presented during the project.
Determine whether or not a Scrum-agile approach was the best approach for the SNHU Travel development project.
Agile Presentation
Finally, you have been asked to put together a PowerPoint presentation for the leadership at your company. You will start by explaining the key facets of the Scrum-agile approach. You will also contrast the waterfall and agile development approaches to help your leadership make an informed decision. You must use properly cited sources to support your points. In your presentation, be sure to address each of the following:Explain the various roles on a Scrum-agile Team by identifying each role and describing its importance.
Explain how the various phases of the SDLC work in an agile approach. Be sure to identify each phase and describe its importance.
Describe how the process would have been different with a waterfall development approach rather than the agile approach you used. For instance, you might discuss how a particular problem in development would have proceeded differently.
Explain what factors you would consider when choosing a waterfall approach or an agile approach, using your course experience to back up your explanation.
What to Submit
To complete this project, you must submit the following:
Sprint Review and Retrospective
Your retrospective should be a 3- to 4-page Word document with double spacing, 12-point Times New Roman font, and APA formatting. Be sure to address all prompts. You are not required to use sources for the retrospective; however, any sources that you do use must be cited.
Agile Presentation
Your agile presentation should be a PowerPoint of at least 5 slides in length, including a references slide. Be sure to address all prompts. You must use properly cited sources in APA style to support your points.

Answers

A sprint review occurs at its conclusion, as its name suggests. It's when the group presents the project's outcomes. The team evaluates their performance in relation to their objectives and talks about how to make the product better.

What is the difference between a sprint review and a sprint retrospective?

The distinguishes sprint reviews from sprint retrospectives. The main distinction is that a Sprint Review concentrates on improvement so the team can produce a better product, but a Sprint Retrospective concentrates on system improvement so the team can work more harmoniously and achieve flow.

While the sprint retrospective focuses on process improvement, the sprint review is more concerned with product development. The alignment of all stakeholders and developers during the sprint review meeting is necessary to produce an efficient, usable, technically sound, and user-centric product.

A sprint review occurs at its conclusion, as its name suggests. It's when the group presents the project's outcomes. The team evaluates if they achieved their objectives and talks about how they might make the product better.

To learn more about sprint review refer to :

https://brainly.com/question/29407828

#SPJ4

java allows you to create objects of this class in the same way you would create primitive variables. group of answer choices scanner random printwriter string

Answers

Java allows you to create objects of string class in the same way you would create primitive variables.

What does Java's String class do?

Character strings are represented by the String class. Java applications implement all string literals as objects of this class, including "abc." Strings are immutable; once they are generated, their characteristics cannot be altered. Mutable strings are supported via string buffers. Since string objects cannot be changed, they may be shared.

What purposes serve the string class?

Strings are collections of characters that are often used in Java programming. Items in the programming language called Java include strings. The String class is provided by the Java platform for producing and modifying strings.

To know more about Java class visit

brainly.com/question/13949269

#SPJ4

true or false : Creative applications of technology can benefit society, but rarely give firms a definite competitive edge since other firms can simply copy the technology.

Answers

The ability to connect creative minds and ideas while also advancing those ideas has greatly improved thanks to technology.

Why is creative technology Important?

A business can get a competitive edge by offering the same good or service at a lower price or by differentiating the offering in a way that makes customers willing to pay more.

It has become more simpler thanks to technology to collaborate with and advance creative brains and ideas. The fusion of creativity and technology has produced ground-breaking new concepts and ways for people to express themselves.

Any digital product or service is improved and enhanced by good design and a positive user experience, and creative technology provides new opportunities for businesses to advertise ideas, tell stories, explore concepts, and forge relationships.

Therefore, the statement is false.

To learn more about technology refer to:

https://brainly.com/question/5502360

#SPJ4

IMAPThis protocol will allow users to maintain messages stored on an email server without removing them from the server.

Answers

The Internet Message Access Protocol (IMAP) is a protocol for gaining access to email or message boards from a mail server or service that may be shared. A client email application can access remote message repositories just like they were local thanks to IMAP.

What does IMAP stand for?

The Internet Message Access Protocol (IMAP) is a protocol for gaining access to email or message boards from a mail server or service that may be shared. A client email application can access remote message repositories just like they were local thanks to IMAP.

We utilize IMAP protocol, but why?

With IMAP, you may use any device to access your email from anywhere. Instead of downloading or saving an email message on your computer when you use IMAP, you read it directly from the server.

To know more about IMAP protocol visit;

https://brainly.com/question/14009005

#SPJ4

When do you use a while loop INSTEAD of a for loop? (Choose the best two answers.)
Group of answer choices

To get input from the user until they input ‘stop’.

To do number calculations.

To repeat code.

When there is an unknown number of iterations needed.

Answers

Answer:

To get input from the user until they input ‘stop’.

When there is an unknown number of iterations needed.

Explanation:

in python
The program is the same as shown at the end of the Merge sort section, with the following changes:
Numbers are entered by a user in a separate helper function, read_nums(), instead of defining a specific list.
Output of the list has been moved to the function print_nums().
An output has been added to merge_sort(), showing the indices that will be passed to the recursive function calls.
Add code to the merge sort algorithm to count the number of comparisons performed.
Add code at the end of the program that outputs "comparisons: " followed by the number of comparisons performed (Ex: "comparisons: 12")
Hint: Use a global variable to count the comparisons.
Note: Take special care to look at the output of each test to better understand the merge sort algorithm.
Ex: When the input is:
3 2 1 5 9 8
the output is:
unsorted: 3 2 1 5 9 8
0 2 | 3 5
0 1 | 2 2
0 0 | 1 1
3 4 | 5 5
3 3 | 4 4
sorted: 1 2 3 5 8 9
comparisons: 8
main.py
# Read integers into a list and return the list.
def read_nums():
nums = input().split()
return [int(num) for num in nums]
# Output the content of a list, separated by spaces.
def print_nums(numbers):
for num in numbers:
print (num, end=' ')
print()
def merge(numbers, i, j, k):
merged_size = k - i + 1
merged_numbers = []
for l in range(merged_size):
merged_numbers.append(0)
merge_pos = 0
left_pos = i
right_pos = j + 1
while left_pos <= j and right_pos <= k:
if numbers[left_pos] < numbers[right_pos]:
merged_numbers[merge_pos] = numbers[left_pos]
left_pos = left_pos + 1
else:
merged_numbers[merge_pos] = numbers[right_pos]
right_pos = right_pos + 1
merge_pos = merge_pos + 1
while left_pos <= j:
merged_numbers[merge_pos] = numbers[left_pos]
left_pos = left_pos + 1
merge_pos = merge_pos + 1
while right_pos <= k:
merged_numbers[merge_pos] = numbers[right_pos]
right_pos = right_pos + 1
merge_pos = merge_pos + 1
merge_pos = 0
while merge_pos < merged_size:
numbers[i + merge_pos] = merged_numbers[merge_pos]
merge_pos = merge_pos + 1
def merge_sort(numbers, i, k):
j = 0
if i < k:
j = (i + k) // 2
# Trace output added to code in book
print(i, j, "|", j + 1, k)
merge_sort(numbers, i, j)
merge_sort(numbers, j + 1, k)
merge(numbers, i, j, k)
if __name__ == '__main__':
numbers = read_nums()
print ('unsorted:', end=' ')
print_nums(numbers)
print()
merge_sort(numbers, 0, len(numbers) - 1)
print ('\nsorted:', end=' ')
print_nums(numbers)

Answers

To add code to the merge sort algorithm to count the number of comparisons performed and  at the end of the program that outputs "comparisons: " followed by the number of comparisons performed check the code given below.

What is sort algorithm?

A sorting algorithm is a set of instructions that takes an input array, applies certain operations to the array (also known as a list), and outputs a sorted array.

Sorting algorithms are frequently covered early on in computer science courses because they offer a simple way to introduce other important concepts like Big-O notation, divide-and-conquer strategies, and data structures like binary trees and heaps.

When selecting a sorting algorithm, many factors need to be taken into account.

"""

Python version: 3.6

Python program to sort a list of numbers in ascending order using merge sort

"""

# add a global variable to count number of key comparisons in merge sort and initialize it to 0

comparisons = 0

def read_nums():

"""

Function that takes no inputs and returns a list of integers entered by the user

"""

# read a string of integers and split it into list of strings using default delimiter whitespace

nums = input().split()

# convert the list of strings to list of integers and return it

return [int(num) for num in nums]

def print_nums(numbers):

"""

Function that takes as input a list of numbers and display the

numbers on screen in one line separated by space ending with a newline

"""

for num in numbers:

 print (num, end=' ')

print()

def merge(numbers, i, j, k):

"""

Function that takes as input a list of numbers and 3 integers

representing the start and ends of the sorted left[i, j] and sorted right[j+1, k] sublists

"""

global comparisons # use the global variable comparisons

# calculate the total size of the list after merging the sublists

merged_size = k - i + 1

# create a list of size merged_size and initialize all elements to 0

merged_numbers = []    

for l in range(merged_size):

 merged_numbers.append(0)

 

# set merge_pos to start index of merged_numbers, left_pos to start index of left sublist and right_pos to start index of right sublist

merge_pos = 0  

left_pos = i

right_pos = j + 1  

# loop until end of a sublist is reached

while left_pos <= j and right_pos <= k:

 comparisons += 1 # increment comparisons by 1

 # current element of left sublist is less than current element of right sublist

 if numbers[left_pos] < numbers[right_pos]:

  # insert current element of left sublist into merged_numbers and increment left_pos by 1

  merged_numbers[merge_pos] = numbers[left_pos]

  left_pos = left_pos + 1

 else:

  # else insert current element of right sublist into merged_numbers and increment right_pos by 1

  merged_numbers[merge_pos] = numbers[right_pos]

  right_pos = right_pos + 1

 merge_pos = merge_pos + 1 # increment merge_pos by 1

# loop to copy the remaining elements of left sublist to merged_numbers

while left_pos <= j:

 merged_numbers[merge_pos] = numbers[left_pos]

 left_pos = left_pos + 1

 merge_pos = merge_pos + 1

 

# loop to copy the remaining elements of right sublist to merged_numbers

while right_pos <= k:

 merged_numbers[merge_pos] = numbers[right_pos]

 right_pos = right_pos + 1

 merge_pos = merge_pos + 1

 

# loop to copy the sorted list from merged_numbers to numbers in the range [i, k]

merge_pos = 0

while merge_pos < merged_size:

 numbers[i + merge_pos] = merged_numbers[merge_pos]

 merge_pos = merge_pos + 1

 

def merge_sort(numbers, i, k):

"""

Function that takes as input an unsorted list of numbers and start and end index

of the list to sort and sorts the list in ascending order using merge sort

"""

j = 0

# current list range contains at least 1 element

if i < k:

 # get the index of middle element of the current range

 j = (i + k) // 2

 # output the range for the left and right sublists to sort

 print(i, j, "|", j + 1, k)

 

 # recursively sort the numbers in the range [i,j] and [j+1, k]

 merge_sort(numbers, i, j)

 merge_sort(numbers, j + 1, k)

 

 # merge the sorted lists [i,j] and [j+1,k] to get the sorted list in the range [i,k]

 merge(numbers, i, j, k)

 

if __name__ == '__main__':

# get the list of numbers entered by the user

numbers = read_nums()

# display the unsorted list

print ('unsorted:', end=' ')

print_nums(numbers)

print()

# sort the list in ascending order using merge sort passing the numbers list and 0 and 1 less than size of list as i and k

merge_sort(numbers, 0, len(numbers) - 1)

# display the sorted list

print ('\nsorted:', end=' ')

print_nums(numbers)

# display the number of comparisons using the global variable

print("comparisons:",comparisons)

# end of program

Learn more about sorting algorithm

https://brainly.com/question/14698104

#SPJ4

Whether you purchase online or by standing in line, the system-level transaction details are essentially the same and they require the same basic database structures and relationships.True
False

Answers

The system-level transaction details are essentially the same whether you make a purchase online or in person, and both scenarios call for the same fundamental database structures and relationships. This assertion is accurate.

An online transaction is what?

Online transactions are used by consumers to pay for the goods or services they purchase.

What happens in the online transaction first?

Registration: Registration for online purchases is the initial step. The customer must register on a website like Flipkart or Amazon in this phase. He must submit his email address, name, address, and other similar facts in order to register; the website keeps and uses these details solely.

To learn more about transaction visit:

brainly.com/question/24730931

#SPJ4

TRUE OR FALSE it is important to know if a computer is byte or word addressable because we need to know how many addresses are contained in main memory, cache, and in each block when doing cache mapping.

Answers

TRUE Since we need to know how several addresses are included in main memory, cache, and each block when executing cache mapping, it is crucial to understand if a computer is bytes or word addressable.

Cache: What is it?

In a computing setting, a cache is a piece of hardware or program that is used to temporarily store something, typically data. To improve the speed of recently or often accessed data, a small quantity of quicker, more expensive memory is employed. Data that has been cached is transiently kept on a local storage medium that is available to the cache clients and unrelated to the main storage. Its central processing unit (CPU), programmes, web browsers, and operating systems all frequently use cache.

To know more about Cache
https://brainly.com/question/15276918
#SPJ4

while performing disk and file maintenance on the company file server, you determine a user in the accounting department has been accidentally saving documents to all shared folders on the file server. the user's computer was recently passed to her from another user in the company, and according to company policy, the user should have access only to the accounting share.

Answers

Note that the incidence that best describes the above situation regarding Disk and file maintenenace is "The principle of least privilege was not followed."

What is the principle of least privilege?

The principle of least privilege (PoLP) is a concept in information security that states that a person or entity should only have access to the data, resources, and programs required to execute a task.

The routine modifications, updating, copying, transferring, or deleting of files on a computer is known as disk and file maintenance. File maintenance is often conducted on computers or servers that serve a large number of files.

Files and folders on a computer's hard disk defragment or break down over time and with continuous use. Computer files that have been fractured are chaotic. As a result, the Operating System (OS) operates slowly and identifies processing issues, according to Support.

Learn more about the Principle of least privilege:
https://brainly.com/question/29793574
#SPJ1

Full Question:

While performing disk and file maintenance on the company file server, you determine a user in the accounting department has been accidentally saving documents to all shared folders on the file server. the user's computer was recently passed to her from another user in the company, and according to company policy, the user should have access only to the accounting share.

What best describes this situation?

when there are several classes that have many common data attributes, it is better to write a(n) to hold all the general data. T/F

Answers

Class attributes are characteristics that belong to the class itself. Every instance of the class will share them. As a result, they are always equal in value.

Which UML part contains a list of the class's data attributes?

A rectangle with three compartments stacked vertically serves as the UML representation of a class.

a group of sentences that specify a class's methods and data properties?

The object made from the class is known as the instance. A class instance is any object that is produced from a class. is a sequence of sentences that specify the methods and data properties of a class. Every method of a class must take the self parameter.

To know more about data attributes visit :-

https://brainly.com/question/29796716

#SPJ4

TRUE/FALSE/excel pie charts: excel pie charts: are known by data analysts as the most accurate kinds of charts. can be used to highlight a datapoint (such as a category on the x axis). can be used to display trendlines. are not good for comparing parts of a whole.

Answers

It's false. Line charts are known by data analysts as the most accurate kinds of charts. It can be used to highlight a data point (such as a category on the x-axis), can be used to display trend lines, and are not good for comparing parts of a whole.

Characteristic of pie chartsIt is a circular graphic divided into a series of slices that represents a particular category. It is good to show and compare the component parts of a whole. All slices of the pie chart must add up to 100.It is visually simpler than other types of charts.

Know more about Excel charts here:

https://brainly.com/question/29756324

#SPJ4

comptia calls regularly updating operating systems and applications to avoid security threats patch management. T/F

Answers

The given statement, compTIA calls regularly updating operating systems and applications to avoid security threats patch management,  is TRUE.

What is compTIA?

CompTIA is not a plan or even a strategy. The Computing Technology Industry Association is what it is, actually. Through training, certifications, education, market research, and philanthropy, CompTIA seeks to encourage the growth of the industry. While providing instruction in contemporary information technology, it also promotes creativity and opens doors by providing applicants with the tools they need to succeed. The company's strategy is also autonomous and vendor-neutral, providing completely agnostic information that doesn't rely on familiarity with certain frameworks or tools.

To know more about compTIA refer:

https://brainly.com/question/28746291

#SPJ4

which of the following components forms the foundation of every computer-based information system and includes resources such as hardware, software, and data center facilities?

Answers

Every computer-based information system is built upon components of the technological infrastructure.

What exactly does "technology infrastructure" mean?

To support the applications and information management needs of the business, the technological infrastructure consists of hardware and software components. Infrastructure for technology has these parts. devices for computers. computer programs. Networking and communication systems.

Why does technology matter going forward?

It can provide a sense of belonging, access, knowledge, and empowerment. As we develop the technologies for the future, we might attempt to create a better world over time. This might mean many things because technology affects every part of our lives.

To know more about technological infrastructure visit:

https://brainly.com/question/13101365

#SPJ4

Other Questions
If you observed that the sperm of a bull could not fuse in a lab dish with the eggs of a cow, you would say that the bull and the cow showedhybrid inviability.gametic isolation.temporal isolation.hybrid infertility.ecological isolation. Rose is angry at her spouse because he refuses to take a vacation. She is so angry that she is shunning him, refusing to talk to him and ignoring his requests to discuss the matter. Rose's tactics are: A)a cry for help, since their relationship is deteriorating. B)her way of getting separateness within the relationship so her identity can be maintained and preserved. C)deliberate and aimed at controlling her spouse. D)an expression of her need to be loved. dr. sardos has the perspective that children that develop antisocial personality disorder are responding to the absence of parental love during infancy, leading to a lack of basic trust by becoming emotionally distant, and they bond with others through the use of power and destructiveness. which perspective does she follow? Given the conditional statement ~p q, which statement is logically equivalent? p ~q~p ~q~q ~p~q p f(x) = x+x-6g(x) = 4x +9Find: g(f(x)) 4.) BLACKCalculate the volumeof 500 g of saltDensity of Salt is 2.16 After the burglary our neighbors came by to give us a ________ hand. Which function is used to display information to the screen in Python? (5 points)print()main()run =show[] Create a table showing all the tasks you and your family do around the house that use water and how often those tasks happen. Leave space for one more column. why is the presence of clay particles important in soil? why is the presence of clay particles important in soil? clay particles allow water to percolate through the soil, making oxygen-rich air pockets available. the negative charges on clay bind to positively charged ions, which would be toxic if absorbed by plants. the negative charges on clay bind to positively charged ions and prevent them from leaching. clay particles provide macronutrients-particularly nitrogen, phosphorus, and potassium. Tell whether the point (13, 17) is a solution to the system of linear equations?y = -x + 30y = x + 6yesno Suppose a rocket is fired vertically upward from the surface of the earth with one-half of the esacpe speed. How far from the center of the earth will it reach vefore it begins to fall back?(let g = 9.8 m/s^2 and Re = 6370 km)A. 1.3 * 104 kmB. 8.5 * 103 kmC. 9.6 * 103 kmD. 2.6 * 104 kmE. 1.9 * 104 kmThe correct answer: B.I do not understand why I am not getting the correct answer. Does 0.010110111011110... represent arational number or an irrational number?Explain your reasoning. three or more consecutive premature ventricular complexes (pvc) at a rate greater than 100 is called: 2. In the space below, write the research question that will guide you in your research,including the three things the assignment calls for. APEX shenandoah is working on a research paper for her psychology course. she prepared her thesis statement and outline, and then developed her first draft. now it is time to review what she has written and make appropriate changes. as she revises her paper, shenandoah should california surf clothing company issues 1,000 shares of $1 par value common stock at $18 per share. later in the year, the company decides to purchase 100 shares at a cost of $21 per share. record the transaction if california surf resells the 100 shares of treasury stock at $23 per share. Which power of Congress helps form a more perfect union?Responsesallocating money to the militaryallocating money to the militaryproviding a check for executive powerproviding a check for executive powerpassing laws to improve the economypassing laws to improve the economycreating courts In return for the relative political autonomy they allowed the religions they conquered, Zhou rulers expected? how would you respond to a naysayer that says store business and concessions business will go down if we give out free hats and free food as part of group sales packages?