Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
# testing_mcp
Testing repository for MCP

## 🎭 A Poem for Coders

```
In the realm of ones and zeros bright,
Where algorithms dance through the night,
Code flows like rivers, clean and true,
Creating worlds both old and new.

Functions call and variables store,
While loops repeat forevermore,
Git commits tell our coding tale,
Through every bug and every fail.

In this repository we test and learn,
Where curiosity makes fires burn,
MCP connections bridge the gap,
Between our dreams and this code map.

So here's to testing, here's to code,
To every merge and episode,
May your builds always pass with green,
And bugs be quickly found and cleaned.
```

📐
🔴

Expand Down
96 changes: 96 additions & 0 deletions merge_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""
Merge Sort Algorithm Implementation

MEMORY: This file contains a simple merge sort implementation in Python.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module docstring includes an internal-sounding "MEMORY:" marker. This reads like an instruction/annotation rather than user-facing documentation; please remove it or rephrase it as normal descriptive text so it doesn’t leak internal metadata into the codebase.

Suggested change
MEMORY: This file contains a simple merge sort implementation in Python.
This file contains a simple merge sort implementation in Python.

Copilot uses AI. Check for mistakes.
The merge sort algorithm uses a divide-and-conquer approach to sort arrays
by recursively dividing the array into halves, sorting each half, and then
merging them back together in sorted order. Time complexity: O(n log n),
Space complexity: O(n).
"""

def merge_sort(arr):
"""
Sort an array using the merge sort algorithm.

Args:
arr (list): The array to be sorted

Returns:
list: A new sorted array
"""
# Base case: arrays with 1 or 0 elements are already sorted
if len(arr) <= 1:
return arr
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring states this returns "A new sorted array", but in the base case (len <= 1) it returns the original list object unchanged. Either return a shallow copy in the base case (to keep the contract consistent) or adjust the docstring to clarify that the input may be returned as-is for small inputs.

Suggested change
return arr
return arr.copy()

Copilot uses AI. Check for mistakes.

# Divide: find the middle point and split the array
mid = len(arr) // 2
left_half = arr[:mid]
right_half = arr[mid:]

# Conquer: recursively sort both halves
left_sorted = merge_sort(left_half)
right_sorted = merge_sort(right_half)

# Combine: merge the sorted halves
return merge(left_sorted, right_sorted)


def merge(left, right):
"""
Merge two sorted arrays into one sorted array.

Args:
left (list): First sorted array
right (list): Second sorted array

Returns:
list: Merged sorted array
"""
result = []
left_index = 0
right_index = 0

# Compare elements from both arrays and add the smaller one
while left_index < len(left) and right_index < len(right):
if left[left_index] <= right[right_index]:
result.append(left[left_index])
left_index += 1
else:
result.append(right[right_index])
right_index += 1

# Add remaining elements from left array (if any)
while left_index < len(left):
result.append(left[left_index])
left_index += 1

# Add remaining elements from right array (if any)
while right_index < len(right):
result.append(right[right_index])
right_index += 1

return result


# Example usage and testing
if __name__ == "__main__":
# Test cases
test_arrays = [
[64, 34, 25, 12, 22, 11, 90],
[5, 2, 4, 6, 1, 3],
[1],
[],
[3, 3, 3, 3],
[9, 8, 7, 6, 5, 4, 3, 2, 1]
]

print("Merge Sort Algorithm Test Results:")
print("=" * 40)

for i, arr in enumerate(test_arrays, 1):
original = arr.copy()
sorted_arr = merge_sort(arr)
print(f"Test {i}:")
print(f" Original: {original}")
print(f" Sorted: {sorted_arr}")
print()
Loading