Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreCourse 1 Submission #2059

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PreCourse 1 Submission
Maria-Fernandes committed Jan 16, 2025
commit fd2f596ce37e3a710f96f4fb3d535b8167f3f99c
File renamed without changes.
6 changes: 3 additions & 3 deletions StackAsLinkedList.java → Exercise_2.java
Original file line number Diff line number Diff line change
@@ -8,11 +8,11 @@ isEmpty O(1)
pop() O(1)
peek() O(1)
*/
public class StackAsLinkedList {
public class Exercise_2 {

StackNode root;

StackAsLinkedList(){
Exercise_2(){
root=null;
}

@@ -78,7 +78,7 @@ public int peek()
public static void main(String[] args)
{

StackAsLinkedList sll = new StackAsLinkedList();
Exercise_2 sll = new Exercise_2();

sll.push(10);
sll.push(20);
8 changes: 4 additions & 4 deletions LinkedList.java → Exercise_3.java
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
insert O(n) n is the number of elements in the linkedlist to be traversed
printList O(n) n is the number of elements in the linkedlist
*/
public class LinkedList {
public class Exercise_3 {

Node head; // head of list

@@ -31,7 +31,7 @@ static class Node {
}

// Method to insert a new node
public static LinkedList insert(LinkedList list, int data)
public static Exercise_3 insert(Exercise_3 list, int data)
{
// Create a new node with given data
Node newNode=new Node(data);
@@ -59,7 +59,7 @@ public static LinkedList insert(LinkedList list, int data)
}

// Method to print the LinkedList.
public static void printList(LinkedList list)
public static void printList(Exercise_3 list)
{
// Traverse through the LinkedList
Node node=list.head;
@@ -75,7 +75,7 @@ public static void printList(LinkedList list)
public static void main(String[] args)
{
/* Start with the empty list. */
LinkedList list = new LinkedList();
Exercise_3 list = new Exercise_3();

//
// ******INSERTION******