Solution File: problem1.java
Design a transaction sorting system for banking audit compliance that processes user-provided transaction records and sorts them based on fee amount using appropriate sorting algorithms depending on dataset size.
- Accepts transaction details from user input
- Stores transaction ID, fee amount, and timestamp
- Uses Bubble Sort for small datasets (≤ 100 transactions)
- Uses Insertion Sort for medium datasets (100–1000 transactions)
- Maintains stable sorting for duplicate fee values
- Applies timestamp comparison when fees are equal
- Detects high-fee outliers (> $50)
- Displays number of passes and swaps (Bubble Sort optimization metrics)
| Dataset Size | Sorting Algorithm Used |
|---|---|
| ≤ 100 | Bubble Sort |
| 100–1000 | Insertion Sort |
| > 1000 | Not supported in this module |
Bubble Sort
- Compares adjacent transaction fees
- Swaps when necessary
- Stops early if already sorted
- Maintains stable ordering
- Tracks passes and swaps
Insertion Sort
- Builds sorted list incrementally
- Uses shifting instead of swapping
- Maintains stability
- Uses timestamp comparison when fees match
Transactions with fee greater than $50 are flagged as high-fee outliers for compliance monitoring and fraud analysis.
Solution File: Problem2.java
Design a client risk ranking system for financial institutions to prioritize high-risk accounts for compliance review and monitoring.
- Accepts client details from user input
- Stores client name, risk score, and account balance
- Uses Bubble Sort for ascending risk ranking visualization
- Uses Insertion Sort for descending priority ranking
- Applies secondary sorting using account balance
- Identifies Top 10 highest-risk clients automatically
- Performs sorting in-place with O(1) extra space
| Sorting Method | Purpose |
|---|---|
| Bubble Sort | Ascending riskScore visualization |
| Insertion Sort | Descending riskScore + balance priority ranking |
Bubble Sort
- Compares adjacent risk scores
- Swaps if out of order
- Tracks number of swaps
- Used for demonstration and audit visualization
Insertion Sort
- Builds sorted priority list incrementally
- Uses account balance as tie-breaker
- Efficient for nearly sorted datasets
- Maintains in-place sorting
Displays Top 10 highest-risk clients after descending sort for:
- KYC prioritization
- AML watchlist screening
- Loan approval risk analysis
Design a trade volume analysis system to process large-scale financial transaction data for market trend reporting and portfolio analytics.
- Accepts trade ID and volume from user input
- Uses Merge Sort for ascending volume ordering
- Uses Quick Sort for descending volume ordering
- Merges two sorted trade datasets
- Computes total trade volume
- Demonstrates divide-and-conquer sorting techniques
| Algorithm | Purpose | Complexity |
|---|---|---|
| Merge Sort | Stable ascending sorting | O(n log n) |
| Quick Sort | In-place descending sorting | Avg O(n log n) |
- Stable sorting algorithm
- Divide-and-conquer approach
- Guaranteed O(n log n) runtime
- Suitable for large datasets
- Uses pivot partitioning
- In-place sorting
- Average O(n log n)
- Worst case O(n²)
- Ascending sorting by volume
- Descending sorting by volume
- Merge two sorted trade sessions
- Compute total trading volume
Design a portfolio sorting system that ranks assets based on historical return rates to support investment recommendation engines and risk-aware asset allocation strategies.
- Accepts asset name, return rate, and volatility from user input
- Uses Merge Sort for ascending return rate ordering
- Uses Quick Sort for descending return rate ordering
- Applies volatility as secondary sorting criteria
- Uses Median-of-3 pivot selection optimization
- Preserves stability during Merge Sort
| Algorithm | Purpose | Complexity |
|---|---|---|
| Merge Sort | Stable ascending sorting | O(n log n) |
| Quick Sort | In-place descending sorting | Avg O(n log n) |
- Stable sorting algorithm
- Preserves original order when return rates match
- Uses auxiliary array during merge step
- Guaranteed O(n log n)
- Median-of-3 pivot selection improves performance
- Secondary sorting using volatility
- In-place sorting
- Average complexity O(n log n)
- Worst-case complexity O(n²)
Design an account ID lookup system for transaction log auditing that efficiently searches for occurrences using Linear Search and Binary Search techniques.
- Accepts transaction account IDs from user input
- Finds first occurrence using Linear Search
- Finds last occurrence using Linear Search
- Uses Binary Search after sorting logs
- Counts duplicate account occurrences
- Tracks number of comparisons performed
- Demonstrates time complexity differences between search algorithms
| Algorithm | Purpose | Complexity |
|---|---|---|
| Linear Search | First & Last occurrence | O(n) |
| Binary Search | Exact match lookup | O(log n) |
- Works on unsorted data
- Sequential scanning approach
- Finds first and last occurrence separately
- Handles duplicate entries naturally
- Worst-case complexity O(n)
- Requires sorted dataset
- Uses midpoint partition logic
- Efficient lookup performance
- Complexity O(log n)
- Expands around midpoint to count duplicates
- First occurrence detection
- Last occurrence detection
- Exact match search
- Duplicate counting
- Comparison tracking
Implement a lookup system for client risk threshold bands using Linear Search and Binary Search variants to support compliance band assignment and dynamic risk pricing.
- Accepts risk band values from user input
- Performs Linear Search on unsorted risk bands
- Uses Binary Search on sorted risk bands
- Finds insertion index for new risk thresholds
- Calculates floor value (largest ≤ target)
- Calculates ceiling value (smallest ≥ target)
- Tracks number of comparisons
| Algorithm | Purpose | Complexity |
|---|---|---|
| Linear Search | Threshold lookup (unsorted) | O(n) |
| Binary Search | Floor / Ceiling / Insert position | O(log n) |
- Searches unsorted risk bands
- Detects exact threshold match
- Reports comparison count
- Floor value detection
- Ceiling value detection
- Insertion position calculation