Skip to content

dskdeveloperrr/problems-week3-4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

problems-week3-4

Problem 1 – Transaction Fee Sorting for Audit Compliance

Solution File: problem1.java

Objective

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.


Features

  • 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)

Algorithm Selection Strategy

Dataset Size Sorting Algorithm Used
≤ 100 Bubble Sort
100–1000 Insertion Sort
> 1000 Not supported in this module

Sorting Logic

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

Outlier Detection

Transactions with fee greater than $50 are flagged as high-fee outliers for compliance monitoring and fraud analysis.


Problem 2 – Client Risk Score Ranking

Solution File: Problem2.java

Objective

Design a client risk ranking system for financial institutions to prioritize high-risk accounts for compliance review and monitoring.


Features

  • 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 Strategy

Sorting Method Purpose
Bubble Sort Ascending riskScore visualization
Insertion Sort Descending riskScore + balance priority ranking

Algorithm Logic

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

Top Risk Detection

Displays Top 10 highest-risk clients after descending sort for:

  • KYC prioritization
  • AML watchlist screening
  • Loan approval risk analysis

Problem 3 – Historical Trade Volume Analysis

Objective

Design a trade volume analysis system to process large-scale financial transaction data for market trend reporting and portfolio analytics.


Features

  • 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

Algorithms Used

Algorithm Purpose Complexity
Merge Sort Stable ascending sorting O(n log n)
Quick Sort In-place descending sorting Avg O(n log n)

Merge Sort Characteristics

  • Stable sorting algorithm
  • Divide-and-conquer approach
  • Guaranteed O(n log n) runtime
  • Suitable for large datasets

Quick Sort Characteristics

  • Uses pivot partitioning
  • In-place sorting
  • Average O(n log n)
  • Worst case O(n²)

Operations Supported

  • Ascending sorting by volume
  • Descending sorting by volume
  • Merge two sorted trade sessions
  • Compute total trading volume

Problem 4 – Portfolio Return Sorting

Objective

Design a portfolio sorting system that ranks assets based on historical return rates to support investment recommendation engines and risk-aware asset allocation strategies.


Features

  • 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

Algorithms Used

Algorithm Purpose Complexity
Merge Sort Stable ascending sorting O(n log n)
Quick Sort In-place descending sorting Avg O(n log n)

Merge Sort Characteristics

  • Stable sorting algorithm
  • Preserves original order when return rates match
  • Uses auxiliary array during merge step
  • Guaranteed O(n log n)

Quick Sort Characteristics

  • 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²)

Problem 5 – Account ID Lookup in Transaction Logs

Objective

Design an account ID lookup system for transaction log auditing that efficiently searches for occurrences using Linear Search and Binary Search techniques.


Features

  • 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

Algorithms Used

Algorithm Purpose Complexity
Linear Search First & Last occurrence O(n)
Binary Search Exact match lookup O(log n)

Linear Search Characteristics

  • Works on unsorted data
  • Sequential scanning approach
  • Finds first and last occurrence separately
  • Handles duplicate entries naturally
  • Worst-case complexity O(n)

Binary Search Characteristics

  • Requires sorted dataset
  • Uses midpoint partition logic
  • Efficient lookup performance
  • Complexity O(log n)
  • Expands around midpoint to count duplicates

Operations Supported

  • First occurrence detection
  • Last occurrence detection
  • Exact match search
  • Duplicate counting
  • Comparison tracking

Problem 6 – Risk Threshold Binary Lookup

Objective

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.


Features

  • 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

Algorithms Used

Algorithm Purpose Complexity
Linear Search Threshold lookup (unsorted) O(n)
Binary Search Floor / Ceiling / Insert position O(log n)

Operations Supported

Linear Search

  • Searches unsorted risk bands
  • Detects exact threshold match
  • Reports comparison count

Binary Search Variants

  • Floor value detection
  • Ceiling value detection
  • Insertion position calculation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages