done Pre course exercise - 1#2419
Open
yashhh-23 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Implements three exercises for stack and linked list data structures in Java, filling in the previously stubbed methods.
Changes:
- Implements array-based
Stackwith push/pop/peek/isEmpty (Exercise_1). - Implements linked-list-based stack with push/pop/peek/isEmpty and renames class to
Exercise_2. - Implements
LinkedListNode constructor,insert, andprintListmethods (Exercise_3).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Exercise_1.java | Implements array-based Stack operations and adds complexity comments. |
| Exercise_2.java | Implements linked-list stack operations; renames class to Exercise_2. |
| Exercise_3.java | Implements Node constructor, insert, and printList for linked list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+57
to
+66
| Node current = list.head; | ||
| while (current != null) { | ||
|
|
||
| // Print the data at current node | ||
|
|
||
| System.out.println(current.data); | ||
| // Go to next node | ||
| current = current.next; | ||
| } | ||
| System.out.println(); | ||
| } |
| public class StackAsLinkedList { | ||
| //Time Complexity : O(1) for push, pop and peek operations | ||
| //Space Complexity : O(n) | ||
| public class Exercise_2 { |
| int top; | ||
| int a[] = new int[MAX]; // Maximum size of Stack | ||
|
|
||
| //Time complexxity : O(1) for push, pop and peek operations |
| current = current.next; | ||
| } | ||
| // Insert the new_node at last node | ||
| current.next = newNode; |
Owner
|
Exercise_1.java (Array-based Stack):
Exercise_2.java (Linked List-based Stack):
Exercise_3.java (Singly Linked List):
General Observations:
Areas for Improvement:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.