9. Find whether a list is even or odd. a) Keep counting. b) Use a bool for flag c) Without any variable int isOdd ( struct node *head ) { Head = head->next; While ( head) { If ( head->next == NULL ) Return 1; Head = head->next->next; } } 10. Reverse a link list with/without recursion. Void reverselist( struct node *head ) { Struct node *prev, *current, *temp; Prev = NULL; Current = head->next; While ( current ) { Temp = current->next; Current->next = prev; Prev = current; Current = temp; } Head->next = prev; } 11. Shuffle two link list of same size. If p and q are head pointers. Struct node *newhead = p; While (q ) { Swap(&p->next, &q); P = p->next; } 12. Merge two sorted link list. 13. Find whether two list are intersecting or not. a) Use negation technique. Traverse list 1 and negate elements. Traverse list 2 and return first negated element. b) Hashtable: insert node in hashtable. If found collision return element. c) Length of list 1 = m length...
Collection of Interview Question on Data structure, Algorithm, Java, C++ and more