Skip to content

Conversation

@rakran
Copy link

@rakran rakran commented Aug 26, 2025

No description provided.

@rakran rakran closed this Aug 26, 2025
@rakran rakran reopened this Aug 26, 2025
@super30admin
Copy link
Owner

The student has implemented two stack data structures - one using an array and another using a linked list. Here's my evaluation:

Strengths:

  1. Both implementations correctly follow the LIFO (Last-In-First-Out) principle of stacks.
  2. The array implementation properly handles stack overflow and underflow with appropriate exceptions.
  3. The code is generally well-structured and readable with clear method names.
  4. Both implementations include all essential stack operations: Push, Pop, Peek, and IsEmpty.

Areas for Improvement:

  1. In the linked list implementation (both Exercise_2 and Exercise_3 which appear identical), returning -1 for empty stack operations (Pop and Peek) is not ideal. It would be better to throw exceptions like in the array implementation for consistency and to avoid ambiguity (since -1 could be a valid stack value).
  2. The linked list implementation is duplicated in both Exercise_2.cs and Exercise_3.cs files - this appears to be a mistake.
  3. The array implementation could benefit from a property to check if the stack is full (similar to IsEmpty), though this isn't strictly necessary.
  4. Some documentation/comments explaining the methods and their behaviors would improve maintainability.
  5. The Peek method in the linked list implementation could throw an exception when the stack is empty, similar to the array version.

Time Complexity:

  • For both implementations, all operations (Push, Pop, Peek, IsEmpty) are O(1) time complexity, which is optimal for stack operations.

Space Complexity:

  • Array implementation: O(n) where n is the maxSize
  • Linked list implementation: O(n) where n is the number of elements

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.

3 participants