Skip to content

Conversation

@neha-pednekar
Copy link

No description provided.

@super30admin
Copy link
Owner

  1. Correctness:

    • Stack implementation (Exercise_1.java) correctly handles push, pop, and peek operations with proper overflow/underflow checks.
    • LinkedList implementation (LinkedList_Exercise_3.java) correctly inserts nodes at the head and prints the list.
    • StackAsLinkedList implementation (StackAsLinkedList_Exercise_2.java) correctly implements stack operations using linked list nodes.
  2. Time Complexity:

    • All implementations correctly state their time complexities in comments.
    • The stack array implementation mentions O(n) for resize case which is good practice to note.
  3. Space Complexity:

    • All implementations correctly state their space complexities in comments.
  4. Code Quality:

    • Code is generally well-structured and readable.
    • Good use of comments explaining time/space complexity.
    • Consistent indentation and formatting.
    • Minor improvement: Could add more comments explaining the logic in methods.
  5. Efficiency:

    • All implementations are efficient for their respective data structures.
    • One potential improvement: In Stack.java (Exercise_1.java), the pop() method checks a.length == 0 which is incorrect - it should check top == -1 like isEmpty() does.
    • In LinkedList_Exercise_3.java, the insert method could be made non-static for better object-oriented design.
  6. Edge Cases:

    • Stack implementations handle empty stack cases well.
    • Could add more test cases for edge scenarios (e.g., multiple pushes/pops, peeking empty stack).

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