1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maksim [4K]
3 years ago
10

Design and implement an algorithm that gets a list of k integar values N1, N2,...Nk as well as a special value SUM. Your algorit

hm must locate a pair of values in the list N that sum to the value SUM. For example, if your list of values is 3, 8, 13, 2, 17, 18, 10, and the value of SUM is 20, then your algorithm would output either of the two values (2, 18) or (3, 17). If your algorithm cannot find any pair of values that sum to the value SUM, then it should print the message
Computers and Technology
1 answer:
Fittoniya [83]3 years ago
6 0

Answer:

The algorithm is as follows:

1. Start

2. Input List

3. Input Sum

4. For i = 0 to length of list - 1

4.1 num1 = List[i]

5. For j = i to length of list - 1

5.1 num2 = List[j]

6. If SUM = num1 + num2

6.1 Print(num1, num2)

6.2 Break

The algorithm is implemented in python as follows:

def checklist(mylist,SUM):

     for i in range(0, len(mylist)):

           num1 = mylist[i]

                 for j in range(i+1, len(mylist)):

                       num2 = mylist[j]

                       if num1 + num2== SUM:

                             print(num1,num2)

                                   break;

Explanation:

I'll explain the Python code

def checklist(mylist,SUM):

This line iterates from 0 to the length of the the last element of the list

     for i in range(0, len(mylist)):

This line initializes num1 to current element of the list

           num1 = mylist[i]

This line iterates from current element of the list to the last element of the list

                 for j in range(i+1, len(mylist)):

This line initializes num1 to next element of the list

                       num2 = mylist[j]

This line checks for pairs equivalent to SUM

                       if num1 + num2== SUM:

The pair is printed here

                             print(num1,num2)

                                   break;

You might be interested in
To delete a row, you must first
Allushta [10]

Do one of the following: To select. Do this. A cell. Click the left edge of the cell. . A row. Click to the left of the row. A column. ...

Under Table Tools, click the Layout tab.

In the Rows & Columns group, click Delete, and then click Delete Cells, Delete Rows, or Delete Columns, as appropriate.


5 0
3 years ago
A type of address translation in which a gateway has a pool of public ip addresses that it is free to assign to a local host whe
krok68 [10]
<span>Dynamic Network Address Translation (DNAT)</span>
7 0
3 years ago
Artemisia gentileschi used directional line brilliantly in her painting judith decapitating holofernes to draw our attention to
andrey2020 [161]

give me a minute to get aanswer


8 0
4 years ago
A local router is configured to limit the bandwidth of guest users connecting to the Internet. Which of the following best expla
mariarad [96]

Answer:

The correct option is d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

Explanation:

Bandwidth can be described as the maximum data transfer that an internet connection or a network has. It gives a measure of the amount of data that can be transmitted over a particular connection in a particular amount of time. For instance, the capacity of a gigabit Ethernet connection is 1,000 megabits per second (Mbps) (which also translates to 125 megabytes per second).

Therefore, when a local router is configured to limit the bandwidth of guest users connecting to the Internet, it will restrict the the maximum amount of data that they can transmit per second.

Therefore, the correct option is d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

3 0
3 years ago
Mario wants to make his document accessible to technology users. He first needs to access the Accessibility Checker. He can do t
Vlada [557]

Answer: see guidelines in explanation

Explanation:

For Mario to make his document accessible to technology assistants, he needs to do the following;

-Access the accessibility checker by clicking the FileHomeReview tab

-Click the InfoNewOpen option

-Click the Check for IssuesManageDocumentProtect, the document icon

-Then, click Check accessibility option, the accessibility pane will open.

-He needs to read the information about errors, warning, tips and steps to take to make his document accessible to other users.

8 0
4 years ago
Other questions:
  • Tiny charts embedded in cells that show a visual trend alongside the data are called __________.
    10·1 answer
  • Are mechanical keyboards more expensive than membrane keyboards?
    9·2 answers
  • What should a system administrator use to disable access to a custom application for a group of users?
    5·1 answer
  • Will a pair of bar magnet ,with keepers on the two ends, act as a magnet
    13·1 answer
  • Which design approach help build sites that optimize varied screen sizes
    5·1 answer
  • The primary purpose of an operating system is: To provide a software interface between the hardware and the application programs
    11·1 answer
  • What tag is used to contain information about a web page, such as the title and related pages?
    12·1 answer
  • Consider the following code segment, where num is an integer variable.
    6·1 answer
  • Como se llama este icono de word
    9·1 answer
  • I've been stuck on these two basic javascript assignments for an embarrassingly long time. The teacher refuses to help me and th
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!