The linked list version of a stack uses node structures and node references instead of an array. This makes the stack have a dynamic size.
typedef struct node* nodeptr;
struct node{
int val;
nodeptr next;
} Node;The value stored in the node.
The pointer connecting the next node.
The function creates a new node and inserts the current top/head node next to the new node.
void push(nodeptr* head, int val){
nodeptr node = malloc(sizeof(Node));
node->val = val;
node->next = *head;
*head = node;
}The function outputs the value in tos and moves tos lower by 1.
int pop(nodeptr* head){
int data = (*head)->data;
nodeptr temp = *head;
*head = temp->next;
free(temp);
return data;
}The free function deallocates the memory of the node pointer so the program reuse the memory from the free'd node.
Because a linked list is dynamic it can never be full.
Functions checks if the stack is empty by checking if head is NULL.
bool isEmpty(nodeptr head){
bool empty = false;
if(head == NULL){
empty = true;
}
return empty;
}Function will output the value in the top of the stack/(the head node).
int peek(nodeptr head){
int data = head->val;
return data;
}Binary Convertion
PostFix Calculator
InFix to PostFix Converter


