Hello!

I was wondering if someone could help with implementation of successor and predecessor in doubly linked list. I have searched everywhere on the internet but have not fould anything useful.

My idea behind this is I look for a number which is larger than users input number but it is smaller than all other numbers. for example L = [3, 2, 7, 5, 8] if I wanna find successor for 3 it has to be bigger than 3 but smaller than other numbers which is 5.

Here is how far i've come:

insertCode:struct node{ int data; struct node *previous; struct node *next; }; struct node *head; struct node *current = NULL; struct node* successor(struct node* head, int data){ struct node* current = head; int curr = current->data; int temp; while(current != NULL) { if(curr > data && curr < max) { temp = curr; } current = current->next; } }