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
How ict tools changed the way we live explain it​
laiz [17]

Answer:

How does ICT change our way of living?

ICT has contributed a lot to change our everyday life such as letter to e-mail, market shopping to on-line shopping, classroom learning to e-learning, etc. This paper present's the effects of ICT as Home and Domestic Activities, Social Networking, Education, Health, Commerce, Banking, and Employment.

5 0
2 years ago
Which of the following shows the correct order of inventions that helped the first computers make calculations?
castortr0y [4]

Answer:

1st - Mechanical Relays, 2nd - Vacuum tubes, 3rd - Transistors

Explanation:

<em>From Tubes...</em>

<em />

The three main components of a basic triode vacuum tube.

The type of tube used in early computers was called a triode and was invented by Lee De Forest in 1906. It consists of a cathode and a plate, separated by a control grid, suspended in a glass vacuum tube. The cathode is heated by a red-hot electric filament, which causes it to emit electrons that are attracted to the plate. The control grid in the middle can control this flow of electrons. By making it negative, you cause the electrons to be repelled back to the cathode; by making it positive, you cause them to be attracted toward the plate. Thus, by controlling the grid current, you can control the on/off output of the plate.

Unfortunately, the tube was inefficient as a switch. It consumed a great deal of electrical power and gave off enormous heat—a significant problem in the earlier systems. Primarily because of the heat they generated, tubes were notoriously unreliable—in larger systems, one failed every couple of hours or so.

<em>...To Transistors</em>

<em />

The invention of the transistor was one of the most important developments leading to the personal computer revolution.The transistor was invented in 1947 and announced in 1948 by Bell Laboratory engineers John Bardeen and Walter Brattain. Bell associate William Shockley invented the junction transistor a few months later, and all three jointly shared the Nobel Prize in Physics in 1956 for inventing the transistor. The transistor, which essentially functions as a solid-state electronic switch, replaced the less-suitable vacuum tube. Because the transistor was so much smaller and consumed significantly less power, a computer system built with transistors was also much smaller, faster, and more efficient than a computer system built with vacuum tubes.

The conversion from tubes to transistors began the trend toward miniaturization that continues to this day. Today’s small laptop PC (or netbook, if you prefer) and even Tablet PC systems, which run on batteries, have more computing power than many earlier systems that filled rooms and consumed huge amounts of electrical power.

8 0
3 years ago
An ip address in the address range 169.254.x.y, used by a computer when it cannot successfully lease an ip address from a dhcp s
Georgia [21]
Yes that is the correct answer


5 0
3 years ago
Which tool is used to test electrical current within a source of power, like a power supply?
yawa3891 [41]

Answer:

Multimeter

Explanation:

A multimeter or multitester or VOM (volt-ohm-milliammeter), is a tool to measure electricity and this tool has some function to measure voltage, current, and resistance. We could find analog and digital multimeters, and we can find expensive certificates and professionals multimeters ($5,000) or cheap ($10).

5 0
3 years ago
What is the Multiplier if the change in RGDP is $525,000,000 and initial spending is $100,000?
OLEGan [10]
The right answer is A
4 0
3 years ago
Other questions:
  • ______________ is only one of the marketing mix tools that acompany uses to achieve its marketing objectives.
    7·1 answer
  • . Business-to-business integration (B2Bi) is vital for efficient and accurate flow of data across internal ISs and external busi
    11·1 answer
  • Which of the following statements is false? People tend to shortcut security procedures because the procedures are inconvenient.
    13·1 answer
  • In addition to using comments and track changes, you can also use the comparison feature for reviewing documents. In this activi
    11·1 answer
  • Creating an accurate inventory is a challenge, given the speed at which data files are created, deleted, moved, and changed. It
    12·1 answer
  • 1. Trust can be built in a relationship if:
    15·1 answer
  • What is an infrastructure dedicated to one organization
    13·1 answer
  • Select the statement which most accurately describes the benefits and drawbacks of working from home and telecommuting.
    13·2 answers
  • Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the cou
    13·1 answer
  • Select the correct answer.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!