Skip to content

Feat/my mergesort#5

Open
Bunsarak27 wants to merge 5 commits into
Goobahfish:mainfrom
Izak8:feat/my_mergesort
Open

Feat/my mergesort#5
Bunsarak27 wants to merge 5 commits into
Goobahfish:mainfrom
Izak8:feat/my_mergesort

Conversation

@Bunsarak27
Copy link
Copy Markdown

Implement a serial my_mergesort(left, right) that will act as the base case for our upcoming parallel_mergesort. This PR does not change threading yet.

What I changed
Added a recursive my_mergesort(int left, int right):
Base case: if (left >= right) return; (0 or 1 element ⇒ already sorted).
Compute mid = left + (right - left)/2 (overflow-safe pattern).
Recurse on [left..mid] and [mid+1..right].
Call merge(left, mid, mid+1, right) to combine the two sorted halves.
Inline comments explaining:
Why the base case uses >=.
Why we split with (right - left)/2.
The invariant that merge() expects inclusive ranges and a split at mid | mid+1.

Izak8 and others added 5 commits October 24, 2025 14:16
Includes a partially-authored README file. However, there are still some changes to make, as there are sections which
we cannot fill out yet. This commit was accidentally authored under my university GitHub identity, woops.

---------

Co-authored-by: Izak Baldacchino <a1830164@student.adelaide.edu.au>
Includes the implementation for the merge function. The makefile has been revamped in order to allow a unit test executable to built and run to test the function.

---------

Co-authored-by: Izak Baldacchino <a1830164@student.adelaide.edu.au>
 Includes the definition for the `buildArgs` function and relevant unit test. Simply
 allocates memory on the heap and constructs a `struct argument` there.
 The function then returns a pointer to this memory on the heap.
Includes a gitignore file which uses the basic C/C++ template
from GitHub. Also includes `compile_flags.txt` in the ignore path.
@Izak8 Izak8 deleted the feat/my_mergesort branch October 30, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants