Skip to content

Completed S30 pre-course2#1890

Open
prenastro wants to merge 2 commits into
super30admin:masterfrom
prenastro:master
Open

Completed S30 pre-course2#1890
prenastro wants to merge 2 commits into
super30admin:masterfrom
prenastro:master

Conversation

@prenastro

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Exercise 1 - Binary Search:

  • Correctness: ✅ Correct implementation. Properly handles all cases: target less than, greater than, and equal to middle element.
  • Time Complexity: ✅ O(logn) - correct
  • Space Complexity: ✅ O(1) - correct
  • Code Quality: Good, but could add type hints for better readability.

Exercise 2 - QuickSort (Recursive):

  • Correctness: ✅ Correct recursive implementation. Partition logic properly places pivot in correct position.
  • Time Complexity: ✅ O(nlogn) average case - correct
  • Space Complexity: ⚠️ O(logn) is the call stack space for average case, but worst case is O(n). The comment is slightly misleading.
  • Code Quality: Well-structured with clear separation between partition and quickSort functions.

Exercise 3 - Find Middle of Linked List:

  • Correctness: ✅ Correct two-pointer (slow/fast) approach. Properly handles edge cases.
  • Time Complexity: ✅ O(n) - correct
  • Space Complexity: ✅ O(1) - correct
  • Code Quality: Clean implementation. The commented-out print statements should be removed for cleaner code.

Exercise 4 - MergeSort:

  • Correctness: ✅ Correct divide-and-conquer implementation. Properly handles merging of sorted subarrays.
  • Time Complexity: ✅ O(nlogn) - correct
  • Space Complexity: ⚠️ O(n) for the auxiliary arrays created during merge - correct
  • Code Quality: Good structure, but the printList function has inconsistent indentation.

Exercise 5 - QuickSort (Iterative):

  • Correctness: ✅ Correct iterative implementation using an explicit stack to simulate recursion.
  • Time Complexity: ✅ O(nlogn) average case - correct
  • Space Complexity: ⚠️ O(logn) average, O(n) worst case - the comment "O(n^2) worst case" for space is incorrect; it should be O(n) for worst case stack depth.
  • Code Quality: Good implementation, but the comment about space complexity is technically wrong.

Overall Assessment:
The student demonstrates solid understanding of fundamental sorting algorithms and data structure operations. All implementations are functionally correct. Main areas for improvement:

  1. Remove commented-out debug code
  2. Fix space complexity comments (especially in Exercise 5)
  3. Add consistent indentation
  4. Consider adding type hints for better code documentation

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