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
13 changes: 13 additions & 0 deletions Algorithms/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// write a function to sort a list of numbers in maopao sort

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

Incorrect comment syntax for Python. Use # instead of // for comments in Python.

Copilot uses AI. Check for mistakes.

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

Spelling error: "maopao" should be "bubble" (as in bubble sort).

Copilot uses AI. Check for mistakes.
def maopao_sort(numbers):

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent naming: the function is named maopao_sort but "maopao" appears to be a misspelling. Consider renaming to bubble_sort to match standard naming conventions for this algorithm.

Copilot uses AI. Check for mistakes.
for i in range(len(numbers)):
for j in range(len(numbers) - 1):
if numbers[j] > numbers[j + 1]:
numbers[j], numbers[j + 1] = numbers[j + 1], numbers[i]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Bubble sort uses wrong index in swap operation

The swap operation incorrectly uses numbers[i] instead of numbers[j] on the right side of the assignment. In bubble sort, adjacent elements at indices j and j + 1 need to be swapped with each other, but this code swaps numbers[j] with the element at the outer loop index i, corrupting the array and producing incorrect sorting results.

Fix in Cursor Fix in Web

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

Critical bug in swap operation: numbers[i] should be numbers[j]. This will cause incorrect sorting behavior as it swaps with the wrong element from the outer loop instead of the adjacent element.

Suggested change
numbers[j], numbers[j + 1] = numbers[j + 1], numbers[i]
numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]

Copilot uses AI. Check for mistakes.
return numbers


// test the function

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

Incorrect comment syntax for Python. Use # instead of // for comments in Python.

Copilot uses AI. Check for mistakes.
numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
print(maopao_sort(numbers))

4 changes: 2 additions & 2 deletions Algorithms/线性结构/栈/Stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Stack::Stack()

bool Stack::isEmpty() const
{
return _top >= 0;
return _top >! 0;
}

bool Stack::isFull() const
{
return _top >= STACK_CAPACITY - 1;
return _top <= STACK_CAPACITY - 1;
}

int Stack::size() const
Expand Down