-
Notifications
You must be signed in to change notification settings - Fork 546
Open
Description
1.Class name violates Java naming conventions // issue 1
public class merge_sort {
Problem: Java class names must start with a capital letter and follow PascalCase (e.g., MergeSort).
This is a core Java standard and affects readability and style consistency across the project.
Fix:
public class MergeSort {
2.Memory inefficiency due to new array creation in every merge // issue 2
int merge[] = new int[ei - si + 1];
Each recursive call of conquer() allocates a new temporary array, increasing memory usage unnecessarily.
This causes extra space complexity (O(n log n)) instead of O(n).
Fix:
Use a single global or reusable temporary array for all merges to improve efficiency:
int[] temp = new int[arr.length];
mergeSort(arr, temp, si, ei);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels