Byll
BAN USER
- 6of 6 votes
AnswersComponents of computer systems often have dependencies -- other components that must be installed before they will function properly. These dependencies are frequently shared by multiple components. For example, both the TELNET client program and the FTP client program require that the TCP/IP networking software be installed before they can operate. If you install TCP/IP and the TELNET client program, and later decide to add the FTP client program, you do not need to reinstall TCP/IP.
- Byll in United States
For some components it would not be a problem if the components on which they depended were reinstalled; it would just waste some resources. But for others, like TCP/IP, some component configuration may be destroyed if the component was reinstalled.
It is useful to be able to remove components that are no longer needed. When this is done, components that only support the removed component may also be removed, freeing up disk space, memory, and other resources. But a supporting component, not explicitly installed, may be removed only if all components which depend on it are also removed. For example, removing the FTP client program and TCP/IP would mean the TELNET client program, which was not removed, would no longer operate. Likewise, removing TCP/IP by itself would cause the failure of both the TELNET and the FTP client programs. Also if we installed TCP/IP to support our own development, then installed the TELNET client (which depends on TCP/IP) and then still later removed the TELNET client, we would not want TCP/IP to be removed.
Write a program to automate the process of adding and removing components. To do this we will maintain a record of installed components and component dependencies. A component can be installed explicitly in response to a command (unless it is already installed), or implicitly if it is needed for some other component being installed. Likewise, a component, not explicitly installed, can be explicitly removed in response to a command (if it is not needed to support other components) or implicitly removed if it is no longer needed to support another component.
I found a reference to this problem online.. Check this for i/o details. This is the exact same problem
http://www.cs.cornell.edu/Info/Courses/Spring-98/CS211/assgts/assgt3/assgt3.pdf| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Algorithm
I am using a LinkedHashSet. Everything else takes O(n). Can any of you review this ?
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
public class Intervals{
static int findRange(Interval[] data){
Set<Integer> res = new LinkedHashSet<Integer>();
for(int i=0;i<data.length;i++){
for(int j=data[i].start;j<=data[i].end;j++){
res.add(j);
}
}
Iterator<Integer> it = res.iterator();
int start = it.next(), last = start, tmp = start, result = 0;
while(it.hasNext()){
tmp = it.next();
if(tmp-last == 1){
last = tmp;
}else{
result += (last-start);
start = tmp;
last = start;
}
}
result += (tmp-start);
return result;
}
static class Interval{
int start, end;
Interval(int x, int y){
this.start = x;
this.end = y;
}
}
public static void main(String[] args){
Interval[] data = {new Interval(1,3), new Interval(2,5), new Interval(8,9)};
System.out.println(findRange(data));
}
}
static int maxSubArraySum(int[] data){
int p1 = 0;
int max_so_far = Integer.MIN_VALUE;
int sum = 0;
for(int i = 0; i < data.length; i++) {
int temp = sum + data[i];
if(temp > max_so_far) max_so_far = temp;
if(temp < 0) {
sum = 0;
} else {
sum = temp;
}
}
return max_so_far;
}
RepClariceWright, abc at 8x8
I am a passionate and dedicated travel agent whose mission is to turn travel dreams into reality. I am crazy ...
RepConnieLavender, Animator at Altera
My name is ConnieLavender . I am working as a Broker associate . I love field work and visiting different places to ...
Repkristenjjimenezk, Analyst at ADP
We Statistical assistants establish and check numerical facts in many different areas of business, government, and industry. Right now I ...
RepHayleyGuez, Malwarebytes customer service at CDK Global
I am Hayley , a freelance artist with 7 years of experience in creating impressionist works. My most recent work was ...
RepCallaRita, techsupport at Knowledge Systems
Hi, I am an Administrative person . It is to develop and sustain an early childhood organisation. I was a teacher ...
Repjennykyiler, Area Sales Manager at AMD
Jenny , an Assistant Secretary with a track record of employer satisfaction in performing various administrative tasks, and completing visual presentations ...
RepKelseyOliver, Security Analyst at Accenture
Kelsey , a Storyboard Artist with demonstrated experience in developing visual templates, storyboards, and sketches. The Award winner (2020) for storyboard ...
Rephejalbbelans299, Animator at ABC TECH SUPPORT
Professional agile project manager with over 2 years of experience in various facets of project management. Implement agile management ideals ...
Repolliejshea, Android test engineer at ABC TECH SUPPORT
Hello I am an application engineer. I love my work very much. Nowadays I am doing some new experiments. Like ...
RepDimaOxygen15, Computer Scientist at Headrun Technologies Pvt Ltd
Hi! all my sweets friends My name is Dimo Oxygen! Now I study in Victoria University of Wellington New Zealand ...
RepTomHolman, abc at A9
I am an expert Metal Refining Furnace Operator And Tender with at least 2 Years of experience, excellent covers all ...
RepCandiRoy, HR at ASU
I am a qualified CEO with experience in overseeing the daily activities of small businesses and large corporations alike. I ...
RepJessicaHanda, Front-end Software Engineer at ABC TECH SUPPORT
Jessica , hard-working Packer with a strong determination to finish all assignments in a timely manner. I have joined a few ...
Repour goal is to help individuals companies and organizations of all kinds to communicate with their clients customer and employees ...
RepIsotherm provides the best roof insulation products in Cape Town, South Africa. We offer insulation products for roofs, water pipes ...
Repriverajenny935, i love my shop piano at xyz
Hello Everyone,My Name is Jenny Rivera .I have been a piano instructor for more than 25 years! I earned ...
RepRocioNavarro189, None at Student
Hello Everyone,My name is Rocio Navarro Form Auckland,NZ,and 31 years old.I am searching for a servant ...
RepVirginialdelmonte, Animator at lostlovebackvashikaran
Have you lost your husband love? And you want to control your husband mind with vashikaran mantra. Guru ji is ...
Repsarahchannah745, Android Engineer at ASAPInfosystemsPvtLtd
Hello, I am an information records clerk.We are responsible for maintaining their company records in a complete and orderly ...
Replimachiya788, Associate at ABC TECH SUPPORT
LeviWebber , is a Housekeeping cleaner at Exact Solutions . I am also exploring new things . Mayong Assam tantrik contact number . Housekeepers ...
Repmarksloan761, Backend Developer at Apache Design
As a Meeting manager at Red Bears Tavern here I am working for approximately ten years . In my daily life ...
Repheldagale, Backend Developer at ASU
Helda , an outgoing Library Assistant capable of working independently in a busy library environment. Great team player adept at performing ...
RepMarshaSimon, Game Programmer at ASU
I am Hayley , a freelance artist with 7 years of experience in creating impressionist works. My most recent work was ...
RepMyraGreen, Accountant at 8x8
I am a dedicated secretary with 2 years of experience excited to join MCL to become a key player in ...
Repmirezwanda, Android test engineer at Arista Networks
Computer database administrator with 3+ years of experience working in Gamma Realty . I often plan security measures, making sure that ...
Replesamean618, Android Engineer at Adap.tv
Working as a Choreographer it's almost 10 years at Happy Bear Investment . Here I am dealing with different people ...
Replinhhonibh, Animator at ABC TECH SUPPORT
I am an experienced, officially certified driving instructor. Excellent driver with a great safety record. Encyclopedic knowledge of traffic rules ...
RepMixMaster, abc at A9
I am mixmaster , a compassionate and dedicated Addictions Nurse with a deep understanding of the intricate challenges associated with addiction ...
RepEliasDavis, Accountant at 8x8
I have a proven track record of success satisfying customers and serving drinks quickly and accurately. I am experienced in ...
I am using a LinkedHashSet. Everything else takes O(n). Can any of you review this ?
- Byll October 01, 2014