Linkedlist//////////////////

how to traverse in opposite direction in linked list

to implement palindrome

hello @sunneykumar309
if u want to traverse from tail to head then u need to add on extra pointer in each node of the linked list that will contain address of previous pointer.

using that previous pointer u can traverse.

or

reverse ur linked list and then traverse from start to end.

for palindrom we use different technique.

what we do is , we first break the list from middle (i,e we get two new linked list ).
then we reverse the first linked list .
and then we compare node’s value of both the list by traversing one by one.
if at any point value dont match then we return false

otherwise at the end we return true

1 Like

for insertion sort in linked list

wait i m replying on ur original thread.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.