Utsav
BAN USER
- 5of 5 votes
AnswersConsider 10 years down the line we have a mobile device which have 10 TB hard disk.Consider the device a file of 5TB and RAM on the device is 1GB. How will you sort the file of 5TB. You can use extra space but RAM is 1GB which is used by other application on the device also.
- Utsav in India| Report Duplicate | Flag | PURGE
Morgan Stanley Senior Software Development Engineer - 0of 0 votes
AnswersWrite a Program in Java, You have an Employee class |
- Utsav in India
class Employee{
String name;
Integer id,
Employee manager
}
Each employee has a manager and the manager of CEO is null. Find all direct and indirect reportees of a manager.
Eg. Say Employee e1 reports to CEO,
e2 and e3 reports to e1,
e4 and e5 reports to e2,
e6 reports to e3.
Then by giving e1 as input, output should be e2, e3, e4, e5 and e6.| Report Duplicate | Flag | PURGE
Morgan Stanley Senior Software Development Engineer Java - 0of 0 votes
AnswersWrite a Java Program in which a class takes four integer arguments as input(a, b, c and d). Do addition of (a+b) on one thread, addition of (c+d) on another thread and multiplication of(a+b) * (c+d)) on main thread.
- Utsav in United States
Like: Thread1 = (a+b)
Thread2 = (c+d)
Main Thread = (Thread1 * Thread2)| Report Duplicate | Flag | PURGE
JP Morgan Senior Software Development Engineer Java
In q and k lang:
d:`ceo`e1`e2`e3!(`e1;(`e2`e3);(`e4`e5);`e6) / Map of Boss to subordinate
f:{l:{d@x}\[x];$[0<(#)m:((,//)l)except(`;x);m;`NoSubordinate]} / function to return subordinate
Test:
f[`e1] /- output `e2`e3`e4`e5`e6
f[`e2] /- output `e4`e5
f[`e4] /- output `NoSubordinate
A solution in q language:
f:{ / function to sort the elements of the array
c0::c1::c2::0; / counter variables
{$[0=x;c0+:1;1=x;c1+:1;2=x;c2+:1;::]} each x; / inner function to count occurrence of each element
:raze [[(c0;c1;c2)]{#[x;y]}'til 3]; / returning the occurrence of 0,1,2 based on count
};
Test:
a:0 1 1 0 2 1 2; / array initialization
f a / calling the function
Output: 0 0 1 1 1 2 2
import java.util.concurrent.Callable;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class AddNumbersUsingExecutorService {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
CopyOnWriteArrayList<Integer> al = new CopyOnWriteArrayList<>();
AddNumService[] an = {new AddNumService(10, 20),
new AddNumService(30, 40)
};
ExecutorService service = Executors.newFixedThreadPool(2);
for(AddNumService an1 : an){
Future<Integer> f = service.submit(an1);
al.add(f.get());
}
service.shutdown();
System.out.println(al.get(0) * al.get(1));
al = null;
}
}
class AddNumService implements Callable<Integer>{
int num1, num2;
public AddNumService(int num1, int num2) {
// TODO Auto-generated constructor stub
this.num1 = num1;
this.num2 = num2;
}
@Override
public Integer call() throws Exception {
// TODO Auto-generated method stub
System.out.println(Thread.currentThread().getName());
return num1 + num2;
}
}
Repirenedpisano, Blockchain Developer at ABC TECH SUPPORT
Hello, I am Irene and I live in Pittsburgh, USA. I am working as A production worker and my duty ...
RepShayneLJohnson, Scientific Officer at Cerberus Capital
I'm Shayne and I have a history of sensitivities that range from dietary issues to skin care and other ...
Repjasonmcarrier, Analyst at Abs india pvt. ltd.
Hello, I live in Houston and I am working as a Convention planner in Roberd's company, I also part ...
Repdaysidbass, Junior programmer at AppPerfect
I have 5 years international experience working in the UK. I assist companies to gain greater value out of their ...
Repsheilaahollins, Blockchain Developer at ASAPInfosystemsPvtLtd
Hello, I am working as a mineralogist studying rocks, gems, and other minerals, including their chemical and crystalline structures. I ...
RepSpent several months writing about boyfriend ki shadi todne ke upay .Spent 2001-2007 donating carp in Las Vegas, NV. My ...
Repkristyrsharp0, AT&T Customer service email at ABC TECH SUPPORT
I love exploring facts about hvac maintenance services brampton. Operated a service repair and maintenance, answered client questions about the ...
Repcherylthurber, Developer Advocate at Absolute Softech Ltd
Hi,I am from Taxes, USA. Passionate multilingual translator with 2.5 years experience in Spanish-English translations.Looking to further ...
Repomarcdei, Android Engineer at Abs india pvt. ltd.
I'm Omar. I am working as a Mail carrier in Manning's Cafeterias company. I love to learn and ...
RepShirleyMHansen, Project Leader at Chelsio Communications
I am Physical Therapy Aide with 3 years experience in hospital. I like to build up my knowledge of various ...
Repjimmybdepuy, Front-end Software Engineer at Arista Networks
Hi, I am Jimmy from los Angeles. I am a painter. I have Knowledge of different types and shades of ...
Repstacyrdavid, Associate at Abs india pvt. ltd.
Hi, I am Stacy working as a Cashier in Dollar store the US. I work for Us government to Collect ...
Repcoragkemmer, Data Scientist at Bankbazaar
Have years of experience to treating variety of outpatients with modalities such as massage, exercise, paraffin, joint mobilization, mechanical traction ...
Repjoycepwise, Blockchain Developer at Accenture
Hello, I’m Joyce. I’m a business developer living in Tampa, FL. I am a fan of music, travel ...
Repanitajrouse, Kuwait airways reservations at American Airlines
I am Anita from Hastings USA. I am working as a manager in Sofa Express company. I Managed the schedules ...
Repethelynfrose, Computer Scientist at 247quickbookshelp
Hello, I am Ethelyn and I live in Lake Worth, USA. I am working as a Dog Trainer and Dog ...
Repkennypmillerk, AT&T Customer service email at 247quickbookshelp
My name is Kenny and I am working as a trusted investor in Pittsburgh USA.I identify / set up a ...
Repjoanarce252, abc at ABC TECH SUPPORT
Hello, I am Joan. I live in Jackson, USA. I am passionate about my work and I am working as ...
RepAmmoBoard, Employee at A9
The best online ammo shop to buy ammunition for your rifles, handguns & shotguns from top brands you like.
RepCarlERhodes, Cloud Support Associate at Baidu
I am an Engineering manager in Mosier USA. I am a freelance events coordinator and a lifetime entrepreneur. I want ...
Open Chat in New Window
k solution:
Test:
- Utsav November 18, 2019> f 0 1 1 0 2 1 2 /- output 0 0 1 1 1 2 2
> f 0 1 2 0 1 2 0 1 2 /- output - 0 0 0 1 1 1 2 2 2