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
Viktor [21]
3 years ago
8

Greedy Algorithm Design

Computers and Technology
1 answer:
Alik [6]3 years ago
8 0

Answer:

The algorithm is as follows:

1. Start

2. Get the number of items (n)

3. Get the current price of the n items (a1, a2..... an)

4. Get the possible hiked price of the n items (b1, b2..... bn)

5. Calculate the difference between the current and hiked prices for each item i.e. d_i = b_i - a_i

6. Sort the differences in descending order (i.e. from the greatest to the least)

7. Buy items in this order of difference

8. Stop

Explanation:

The algorithm is self-explanatory; however, what it does is that:

It takes a list of the current price of items (say list a)

E.g: a = [100, 150, 160]

Then take a list of the hiked price of the items (say list b)

E.g: b = [110, 180, 165]

Next, it calculates the difference (d) between corresponding prices d_i = b_i - a_i

d = [(110 - 100),(180-150),(165-160)]

d = [10,30,5]

Sort the difference from greatest to lowest (as the difference is sorted, lists a and b are also sorted)

d = [30,10,5]

a = [150, 100, 160]

b = [180, 110, 165]

If there is no hike up to item k, the couple would have saved (i = 1 to d[k-1])

Assume k = 3

The couple would have saved for 2 item

Savings = d[1] + d[2]

Savings = 30 +10

Savings = 40

The saved amount will then be added to the kth item in list a i.e. a[k](in this case k = 3) in order to buy b[k]

Using the assumed value of k

a[k] = a[3]

a[3] = 160

b[3] = 165

Add the saved amount (40) to a[3]

New\ Amount = 40 + 160

New\ Amount = 200

This new amount can then be used to buy b[3] i.e. 165, then they save the change for subsequent items

You might be interested in
a machine needs a minimum of 100 sec to sort 1000 names by quicksort what is the approximate worst case time needed to sort 100
alexira [117]

Answer:

6.7seconds

Explanation:

4 0
2 years ago
The author of ""Cyber-psychopathy: What Goes On in a Hacker’s Head"" states that a crucial component of computer hacking lies in
slega [8]

Answer: The statement implies that the hackers psychologically manipulate the human to access the information they need.

Explanation: The author states that the hacker does not only exploits technology to get system access or to gather information. But there is another pivotal part of hacking. He refers to this part as "social engineering".

Social engineering from information security perspective means manipulate human emotions and convincing them to disclose some confidential information. Hacker often hacks or defrauds after gaining confidence and trust of a person.

Phishing is an example. It is a fraudulent technique for getting some secret information. Phisher sends an email pretending to be from some reputable organization to persuade people to divulge private information like passwords and credit card numbers, ATM card pin etc.

5 0
3 years ago
Amanda wants to prevent sensitive data from being sent via email in her organization. What type of agent software can she instal
melamori03 [73]

The type of agent software can she install on her systems to identify properly categorized or tagged information before it leaves the company is a strong antivirus software.

<h3>What are some ways to handle against email phishing attacks?</h3>

People are known to have system and they are said to have different kinds of attacks from outside sources. The ways to protect yourself from Phishing are:

  • Be on guard towards the  handing of sensitive information.
  • Never click on alarming messages.
  • Do not open any form of attachments that is suspicious or strange.

Learn more about  phishing attacks from

brainly.com/question/2537406

8 0
1 year ago
Images are available in many formats, such as tif, bmp, gif, jpeg, and ____.
Lerok [7]
<span>Images are available in many formats, such as tif, bmp, gif, jpeg, and png.

</span>Hope that helps.
7 0
2 years ago
Submit your newsletter that includes the following: two or three columns a title at least three graphics, but not more than six
BigorU [14]

God Is Good He Will Always Help You He Is Good And Always Good!!

If God Is For Us Who Can Be Against us?? Romans 8:31

7 0
2 years ago
Read 2 more answers
Other questions:
  • 2. Statement: "I don't agree with you." Nonverbal gesture: Type of gesture:
    6·1 answer
  • In cell h15 enter a vlookup function to determine the 2018 percentage of total attendance for the city listed in cell h14. Use t
    7·1 answer
  • What to do when the tool bar for paint tool sai dissapears?
    12·1 answer
  • The optional feature in a business letter is
    10·1 answer
  • why is the disk method a special case of the general slicing​ method? choose the correct answer below. a. the cross sections of
    7·1 answer
  • . Write a toString method for this class. The method should return a string containing the base, height and area of the triangle
    10·1 answer
  • Computer application just help me with it all ?
    8·1 answer
  • Office 365 ProPlus can be deployed to your enterprise. When doing so, which tool enables you to choose the language, hardware ar
    5·1 answer
  • Are there any Potential Dangers in Artificial Intelligence?
    11·2 answers
  • Type the correct answer in each box. Spell all words correctly, and use numerals instead of words for numbers. If necessary, use
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!