Alright so I am trying to insert nodes into a linked list but also I want them to be sorted right away
I think I got most of it except I am struggling when it comes to inserting it to the middle of the table
temp -> price = price;
if((*head) == NULL && (*tail) == NULL)
{
temp->next = NULL;
temp->prev = NULL;
(*head) = temp;
(*tail) = tail;
}
else if(price > (*head)->price)
{
temp->next = (*head);
temp->prev = NULL;
(*head)->prev = temp;
(*head) = temp;
}
else if (price < (*tail->price))
{
temp->next = NULL;
temp->prev = (*tail);
(*tail)->next = temp;
(*tail)= temp;
}
else
{
temp = (*head);
while(price < temp->price && temp != NULL)
temp = temp->next;
temp=temp->prev;
//I AM STUCK OVER HERE
}