Question: my code is filling with the same element on return and I dont know why Running sort: Heap K - Way Merge with 8 items

my code is filling with the same element on return and I dont know why
Running sort: Heap K-Way Merge with 8 items
52843716
firstIndex: 0, lastIndex: 8
numValues: 8, subarraySize: 4, remaining: 0
firstIndex: 0, lastIndex: 4
numValues: 4, subarraySize: 2, remaining: 0
firstIndex: 0, lastIndex: 2
numValues: 2, subarraySize: 1, remaining: 0
Constructing MinHeap...
Source Array Size: 2
Source Array: 52
Adding Subarray to Heap...
Subarray Contents: 5
Adding Subarray to Heap...
Subarray Contents: 2
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
firstIndex: 2, lastIndex: 4
numValues: 2, subarraySize: 1, remaining: 0
Constructing MinHeap...
Source Array Size: 2
Source Array: 22
Adding Subarray to Heap...
Subarray Contents: 2
Adding Subarray to Heap...
Subarray Contents: 2
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
Constructing MinHeap...
Source Array Size: 4
Source Array: 2222
Adding Subarray to Heap...
Subarray Contents: 22
Adding Subarray to Heap...
Subarray Contents: 22
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
firstIndex: 4, lastIndex: 8
numValues: 4, subarraySize: 2, remaining: 0
firstIndex: 4, lastIndex: 6
numValues: 2, subarraySize: 1, remaining: 0
Constructing MinHeap...
Source Array Size: 2
Source Array: 22
Adding Subarray to Heap...
Subarray Contents: 2
Adding Subarray to Heap...
Subarray Contents: 2
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
firstIndex: 6, lastIndex: 8
numValues: 2, subarraySize: 1, remaining: 0
Constructing MinHeap...
Source Array Size: 2
Source Array: 22
Adding Subarray to Heap...
Subarray Contents: 2
Adding Subarray to Heap...
Subarray Contents: 2
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
Constructing MinHeap...
Source Array Size: 4
Source Array: 2222
Adding Subarray to Heap...
Subarray Contents: 22
Adding Subarray to Heap...
Subarray Contents: 22
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
Constructing MinHeap...
Source Array Size: 8
Source Array: 22222222
Adding Subarray to Heap...
Subarray Contents: 2222
Adding Subarray to Heap...
Subarray Contents: 2222
Merging sorted subarrays:
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
Smallest element: 2
22222222
Sorted!
Sort completed in 35.008 milliseconds
Passed Test 1. Merge sort
----------------
Passed 1 out of 4 group tests
--End of tests-
 my code is filling with the same element on return and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!