Write an algorithm to help james find the sets of foreground

Assignment Help Other Subject
Reference no: EM132348206

Assignment -

James is working on a system that divides applications to a mixes cluster of computing devices.eaxch application is identified by an integer ID, requires a fixed non-zero amount of memory to execute,and is defined to be either a foreground or background application. IDs are guaranteed to be unique within their own application type, but not access types.

Each device should be signed two applications at once, one foreground application and one background application, Devices have limited amount of memory and cannot execute applications that require more memory than the available memory .The goal of the system is to maximise the total utilization of the memory of a given device. A foreground/background application pair is considered to be optimal if there does not exist another pair that uses more memory than this pair,and also has a total less than or equal to the total memory of the device. For example, if the device has 10MB memory a foreground/background pair using a sum total of 9MB memory would be optimal if there does not exist a pair that uses a sum total of 10MB, but would not be optimal if such a pair did exist.

Write an algorithm to help James find the sets of foreground and background application pairs that optimally utilize the given device for a given list of foreground applications and a given list of background applications.

Input - The input to the function/method consists of three arguments:

devicecapacity, an integer representing the maximum capacity of the given device;

forgroundAppList, a list of pairs of integers where the first integer represents the unique ID of a foreground application and the second integer represents the amount of memory required by this application;

backgroundAppList, a list of pairs of integers where the first integer represents the unique ID of a background application and the second integer represents the amount of memory required by this application.

Output - Return a list of pairs of integers representing the pairs of IDs of foreground and background applications that optimally utilize the given device. If no pair is possible ,return a list with empty pair.

Examples -

Example 1:

input:

deviceCapacity =7

foregroundAppList=[[1,2],[2,4],[3,6]]

backgroundAppList=[[1,2]]

output[[2,1]]

explination: There are only three combinations, [1,1],[2,2] and [3,1], which use a total of 4,6 and 8 MB memory ,respectively. Since 6 is the largest use that does not exceed 7,[2,1] is the only optimal pair

Example 2:

Input:

device capacity=10

foregroundAppList=[[1,3],[2,5],[3,7],[4,10]]

backgroundAppList=[[1,2],[2,3],[3,4],[4,5]]

output:

[[2,4],[3,2]]

Explanation: There are two pairs of foreground and background applications possible that optimally utilizes the given device.

Application 2 from foregroundAppList uses 5 memory units, and application 4 from backgroundAppList also uses 5 memory units. Combined, they add up to 10 units of memory.

Similarly application 3 from froegroudAppList uses 7 memory units, and application 2 from backgroundAppList uses 3 memory units these also add up to 10 units of memory.

Therefore, the pairs of foreground and background applications that optimally utilize the device are [2,4] and [3,2].

Code:

importjava.util.List;

public class Solution

{

List<List <Integer>> optimalUtilization(int deviceCapacity,List<List<Integer>> foregroundAppList,List<List<Integer>> backgroundAppList)

{

//write your code here

}

//Method Signature Ends

}

Reference no: EM132348206

Questions Cloud

Explain how you would characterize their corporate strategy : Examine the corporate Web site for your selected company and explain how you would characterize their corporate strategy.
Write an algorithm to output the minimum possible time : Assignment - Write an algorithm to output the minimum possible time to put the n parts together and build the final product
Why is effective and frequent communication : Why is effective and frequent communication so critical to a successful change effort? Describe either a good or a bad example of this from your organization
Which of the following is the most appropriate factor : Level 3 Advanced Certificate in Procurement and Supply Operations- AC4 - Inventory and logistics operations-Which of the following describes class C items?
Write an algorithm to help james find the sets of foreground : Write an algorithm to help James find the sets of foreground and background application pairs that optimally utilize the given device
Type of organisation and the industry sector : Managers should be able to outline the environmental or sustainability legislation, regulations and codes of practice applicable to the organisation
Contemporary project management-planning the project : Choose journal article regarding topics covered in this class thus far. The review will discuss summary of article along with relevant points made by author
Procedures in the stakeholder engagement process : How should you adhere to relevant organisation policies and procedures in the stakeholder engagement process?
Literature review about the roles of the board of directors : Examine the corporate governance report of a selected public listed company to ascertain the compliance of the company with the Code of corporate governance

Reviews

Write a Review

Other Subject Questions & Answers

  What was the important event that happened that year

Scholars often identify the year 313 AD/CE as a crucial turning point for Christianity. First, what was the important event that happened that year? Second, provide examples from the chapter that support the claim that 313 was a very important yea..

  Provide a description of computer-assisted coding

Provide a description of computer-assisted coding. Give at least two pros and two cons of this type of technology.

  How do you manage the failures that come with the job

What are the ethical concerns that come with a career in being a University professor? Life is a matter of ups and downs, how do you manage the failures that come with the job?

  Identify with the individualist culture

If you are from the USA you most likely identify with the individualist culture. What communication traits do you possess that exemplify your culture ? Who gave you those traits?

  Any fruit that is infected is also rotten

Any fruit that is infected is also rotten. No fruit that was inspected is infected. Therefore, any fruit that was inspected is safe to eat. Which statement, if added to the argument above, would ensure that the conclusion would logically follow from ..

  Explain the importance of trusting the process

Create an outline of the whole systems approach for a consulting problem within an organization that deals with employee safety.

  Describe the procedural history of the case

Read the case and submit a case brief, analyzing the results of the case and explaining the applicable law. In your case brief, describe the procedural history of the case and the relevant facts of the case;

  Increase awareness of cultural competence

Perform an internet search on cultural competence, assumptions, biases, and stereotypes. Locate at least three peer reviewed references.

  Show your ability to organize data into meaningful sets

a researcher has recorded the reaction times of 20 individuals on a memory assessment. the following table indicates

  Individual assignment hr focus

Individual Assignment HR Focus

  Write about both sides of the grievance union and management

Write about both sides of the grievance - both the union and management. Explain in paragraph form what the arguments are of both sides. Include a total of 4 arbitration cases that have been decided on similar facts. This means that you will explai..

  Language development increases in amount and complexity

children's language development increases in amount and complexity. They are exposed to more direct instruction of phonetic, semantic, syntactic, morphemic and pragmatic knowledge. Some believe their natural development may be stinted by the regiment..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd