Answers for "mid of linked list"

C++
0

mid of linked list

            while (fast_ptr != NULL && fast_ptr->next != NULL)
            {
                fast_ptr = fast_ptr->next->next;
                slow_ptr = slow_ptr->next;
            }
            cout << "The middle element is [" << slow_ptr->data << "]" << endl;
Posted by: Guest on January-31-2022

Browse Popular Code Answers by Language