Is it possible to insert an unsigned long into a linked list ordered from smallest to largest Without using malloc or free.
The use of malloc and free is dependent on how you implement your linked list and not on the operations like insert / delete.
I have used malloc and free in my code. I want to know if I could avoid using them in my inserting function
No you cannot because if you use malloc for each node, you will need to use malloc before you can assign data to it. If you would have done such that you malloc few nodes in one go, you can avoid malloc and free before each operation.
Linked lists are a way to store data with structures so that the programmer can automatically create a new place to store data whenever necessary. Specifically, the programmer writes a struct definition that contains variables holding information about something and that has a pointer to a struct of its same type (it has to be a pointer--otherwise, every time an element was created, it would create a new element, infinitely). Each of these individual structs or classes in the list is commonly known as a node or element of the list.
The only way to avoid using malloc during insertion of a new element in the array is to use an entry that was preallocated in some way. However that only means the memory was allocated at some other time. When inserting into a linked list you usually create a new entry, which means allocating memory. So to insert without using malloc is a contradiction of terms. If you want to avoid memory fragmentation caused by repeatedly lengthening and shortening the list then you could only allocate new nodes and never free them, and mark each node as either used or unused (and further, to allocate a batch of new nodes at a time). With at least one unused node in the list you could then insert without allocating. Could you explain what problem you are trying to solve? Why do you want to insert without calling malloc?