Merge branch 'main' into csci

This commit is contained in:
Mike 2024-02-01 19:44:34 -05:00 committed by GitHub
commit ddba85e74b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 10 deletions

1
.gitignore vendored
View file

@ -129,3 +129,4 @@ dist
.yarn/install-state.gz
.pnp.*
.DS_STORE

View file

@ -5,16 +5,6 @@ class LinkedList {
this.head = null;
}
getHead() {
return this.tail;
}
getTail() {
return this.head;
}
getSize() {
return this.size;
}
append(value) {
let newNode = new Node(value);
@ -27,6 +17,7 @@ class LinkedList {
}
if (this.tail == null) {
this.tail = newNode;
}
this.size += 1;
@ -34,6 +25,7 @@ class LinkedList {
prepend(value) {
let newNode = new Node(value);
if (this.tail == null) {
this.tail = newNode;
if (this.head == null) {
@ -43,6 +35,7 @@ class LinkedList {
const temp = this.tail;
temp.nextNode = newNode;
this.tail = newNode;
}
this.size += 1;
}
@ -66,6 +59,7 @@ class LinkedList {
this.tail = null;
} else {
this.head = this.head.nextNode;
}
this.size -= 1;
}
@ -82,6 +76,7 @@ class LinkedList {
}
return searchNodes(this.head, value);
}
find(value) {
@ -97,12 +92,14 @@ class LinkedList {
}
return searchNodes(this.head, value, index);
}
insertAt(value, index) {
let previousNode = null;
let newNode = new Node(value);
let currentNode = this.head;
let count = 0;
if (index === 0) {
@ -132,6 +129,7 @@ class LinkedList {
removeAt(index) {
let previousNode = null;
let currentNode = this.head;
let count = 0;
if (index === 0) {
@ -160,6 +158,7 @@ class LinkedList {
let nodes = [];
let current = this.head;
while (current != null) {
nodes.push(current.value);
current = current.nextNode;
@ -212,4 +211,5 @@ list.removeAt(0);
list.toString();
console.log("Removing element Deez Nuts");
list.removeAt(3);
list.toString();