Skip to content

Conversation

@piyushd-techie93
Copy link

added all 3 examples in Java . added sample file with approach

@piyushd-techie93
Copy link
Author

added files

@super30admin
Copy link
Owner

Let me evaluate each exercise separately:

Exercise_1 (Array-based Stack):
Strengths:

  • Basic stack operations (push, pop, peek, isEmpty) are implemented correctly
  • Handles stack overflow and underflow conditions
  • Constructor initializes top pointer correctly

Areas for Improvement:

  • The constructor parameter is unused (should be parameterless)
  • Missing return statement in push() method (compilation error)
  • peek() method has inconsistent behavior (prints and returns)
  • Missing time/space complexity comments at top
  • Could use more descriptive error messages
  • No comments explaining the approach

Exercise_2 (Linked List-based Stack):
Strengths:

  • Correct implementation using linked list nodes
  • Proper handling of empty stack cases
  • Good use of root pointer to track top
  • Clear output messages

Areas for Improvement:

  • isEmpty() prints a message which may not be expected behavior
  • peek() doesn't return anything when stack is empty (just prints)
  • Missing time/space complexity comments
  • Could benefit from more comments explaining the approach

Exercise_3 (Linked List Implementation):
Strengths:

  • Correct implementation of basic linked list operations
  • Proper node insertion at end of list
  • Clear print method

Areas for Improvement:

  • Static head variable is problematic (should be instance variable)
  • insert() method takes LinkedList parameter but doesn't use it
  • Missing time/space complexity comments
  • Could use more comments explaining the approach
  • No error handling for edge cases

General Observations:

  1. Missing time/space complexity analysis in all files
  2. Some methods have inconsistent return behaviors
  3. Could benefit from more comments explaining the approach
  4. Some minor compilation issues (like missing return in push())
  5. Good separation of concerns between exercises
  6. Overall structure is clear but could be more polished

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