Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

create struct node with two types: int data to store data and node* next as a

pointer to link another node

create a node* head as a null pointer first

fucntion add an element to the tail


void add(int x)
create a node* temp and store the x, then point it to NULL
if head is a nullptr:
point head to temp
else:
create a node* run
while run is not at the end of the stack:
link run to itself's next
then link run to temp

fucntion delete an element at the head


void del()
if head is not null:
creat node* temp and link it to head
link head to it's next
then delete temp
if it's null, do nothing

You might also like