Write code to reverse a linked list? ( do not use libraries like stack)
Anonym
Could someone please tell if this answer is a correct one. This is assuming that the linked list is a single linked list. Top is a pointer to the first element of the linked list prev_temp, Temp and next_temp are pointers which are used to actually reverse the linked list here is the algorithm /* Code starts from here */ prev_temp = NULL; temp = Top; while(temp != NULL) { next_temp = temp->next; temp->next = prev_temp; prev_temp = temp; temp = next_temp; } top = prev_temp;