Assessment Pattern: 97 Q( 2 Coding + 95 Mcqs)
| No. | Section | Questions | Duration |
|---|---|---|---|
| 1 | Coding (Advance programming fundamentals) | 1 | 40 minutes |
| 2 | Coding (Basic Programming) | 1 | 15 minutes |
| 3 | Design Pattern (Advanced) | 15 | 6 minutes |
| 4 | Design Pattern (Basic) | 15 | 4 minutes |
| 5 | Fundamental AI know how, Cloud Services Exposure | 25 | 10 minutes |
| 6 | DB Concepts - ACID properties, Transactions, DB Fundamentals | 25 | 10 minutes |
| 7 | Aptitude | 15 | 10 minutes |
Implement an airport baggage sorting system that efficiently categorizes items by destination using parallel processing. Each baggage item, identified by its name and destination, should be grouped accordingly, leveraging the Fork-Join Framework for parallel sorting.
Goal
compute() function description.Note:
class BaggageItem
Each object of this class contains:
name: The bag's name, e.g., "BagA".destination: The bag's destination, e.g., "Paris".class BaggageSorter extends RecursiveTask<Map<String, List<BaggageItem>>>
It handles parallel sorting of baggage items using the Fork-Join Framework, extending RecursiveTask for recursive task decomposition. Its attributes are:
baggageItems: A list of all baggage items to sort.start: The start index of the list for the current task.end: The end index of the list for the current task.Map<String, List<BaggageItem>> sortBaggage(int numberOfBags, List<BaggageItem> baggageItems)
The method manages parallel sorting of baggage items.
ForkJoinPool.BaggageSorter task to perform parallel sorting.Complete the function compute() in the editor. It sorts the baggage items based on their destinations either using sequential sorting or in parallel using the Fork-Join Framework.
Function Parameters
No parameters, but the class has access to baggageItems, start, and end to define the scope of work for each subtask.
Returns
Map<String, List<BaggageItem>>: where the key is a destination, e.g., "Paris", and the value is a list of baggage items assigned to that destination.
Boilerplate code template
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.concurrent.*;
// Class representing a baggage item with a name and destination
class BaggageItem {
private final String name;
private final String destination;
public BaggageItem(String name, String destination) {
this.name = name;
this.destination = destination;
}
public String getName() {
return name;
}
public String getDestination() {
return destination;
}
@Override
public String toString() {
return name + ": " + destination;
}
}
// RecursiveTask for parallel sorting of baggage items by destination
class BaggageSorter extends RecursiveTask<Map<String, List<BaggageItem>>> {
private final List<BaggageItem> baggageItems;
private final int start;
private final int end;
public BaggageSorter(List<BaggageItem> baggageItems, int start, int end) {
this.baggageItems = baggageItems;
this.start = start;
this.end = end;
}
@Override
protected Map<String, List<BaggageItem>> compute() {
// Write code here
}
}
Arista • Pending
Arista • Pending
BlackRock • Pending
BlackRock • Pending