InterviewSolution
Saved Bookmarks
| 1. |
Write down a C++ function to display all the nodes in a circular linked list. |
|
Answer» A C++ function to display all the nodes in a circular LINKED list is GIVEN below: // A C++ Method for displaying all the nodes in a Circular linked list void displayCircularList(NODE* root){ Node* a = root;/* Provided circular linked list has at least one node, traverse the list*/ if (root) { // Display all the nodes until the FIRST node appears again do { cout << a -> val << " "; a = a -> next; } while (a != root); }} |
|