Why it is no giviing o/p of the code?
In the insert functions, you have to pass the head pointers by reference. And for doing this, it should be node *&head in the parameters. Also you should put a return statement if head is NULL. I modified your code. Check it out -