change next to prev, just makes more sense

This commit is contained in:
Emanuel Rodriguez 2023-06-30 07:46:20 -07:00
parent 30315e6d29
commit 722aecd6dc
1 changed files with 4 additions and 4 deletions

View File

@ -17,7 +17,7 @@ pop: len = 0 /[A]/
typedef struct Node {
int value;
struct Node* next;
struct Node* prev;
} Node;
typedef struct Stack {
@ -28,7 +28,7 @@ typedef struct Stack {
Node* new_node(int value) {
Node* n = malloc(sizeof(Node));
n->value = value;
n->next = NULL;
n->prev = NULL;
return (n);
}
@ -47,7 +47,7 @@ bool pop(Stack* s) {
if (s->length == 1) {
s->head = NULL;
} else {
s->head = n->next;
s->head = n->prev;
}
free(n);
s->length--;
@ -67,7 +67,7 @@ void push(Stack* s, Node* n) {
s->length++;
} else {
// make the old head point to what will be the new head
n->next = s->head;
n->prev = s->head;
// make the head point to n now
s->head = n;
s->length++;