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
What is the "key" to a Caesar Cipher that someone needs to know (or discover) to decrypt the message? a) A secret word only know
Tpy6a [65]

Answer:

The number of characters to shift each letter in the alphabet.

Explanation:

Caeser Cipher is the technique of encryption of data, to make it secure by adding characters between alphabets. These are the special characters that make the message secure while transmitting.

According to the standards, For Decryption, we remove these special characters between alphabets to make message understandable.

<em>So, we can say that,to de-crypt the message, the number of characters to shift each letter in the alphabet.</em>

3 0
3 years ago
TRUE/FALSE<br><br> The Interrupt Flag (IF) controls the way the CPU responds to all interrupts.
Nastasia [14]

Answer: True.

Explanation:

The value of the IF is very important to respond to the interrupts in the OS. It is a system flag bit. All the hardware interrupts will be handled if the flag value is set to 1 else all interrupts will be ignored. It takes two values either 1 or 0.

3 0
4 years ago
Explain difference static IP address, Dynamic IP address.
elena55 [62]
A static IP address is constant and does not change. A dynamic IP address changes constantly, usually in intervals.
7 0
3 years ago
Discuss how you think building in accessibility to your website would impact the design and implementation process.
Licemer1 [7]

Answer:

 The accessibility is the ability where all the condition are access easily and web accessibility is one of the important way where the user can easily access the internet and web on the system.

Building the accessibility is very important as it help to show the people skills and talent with all the disabilities by using the website.

The accessibility of the website does not harm any type of website design and the implementation process as it enhance the features of the website by including various types of animation and the graphics designs. We can also include various types of features so that it can easily understandable by the users and looks more attractive.

5 0
4 years ago
Write a Python Program that:
Andreyy89

Answer:

To collect data from an user you need to use an input

Explanation:

Therefore,

firstName = input("First name: ")

ageInYears = input("Age in Years: ")

weightInKilograms = input("Weight in Kilograms: ")

and then print all the values:

print(firstName, int(ageInYears), float(weightInKilograms))

5 0
3 years ago
Other questions:
  • Internet is a boon or curse
    15·1 answer
  • Which kind of image is indispensable and needs added text to go with it
    7·1 answer
  • Which device can be installed on the edge of your network to allow multiple remote users to connect securely to your internal en
    9·1 answer
  • Which is the most used operating system? A. Windows B.Linux C.Leopard D. DOS
    14·2 answers
  • ossless compression tools generally use either Huffman coding or Lempel-Ziv-Welch (LZW) coding. Discuss the advantages and disad
    8·1 answer
  • Consider the following code:
    10·1 answer
  • For each of the following memory accesses indicate if it will be a cache hit or miss when carried out in sequence as listed. Als
    15·1 answer
  • How many types of window in Qbasic​
    7·1 answer
  • 1. What is hydrolics?​
    6·1 answer
  • Question 5 of 10
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!