void linkedListTraversal(Node* ptr) {
while (ptr != NULL) {
cout << " Element : " << ptr->data << endl;
ptr = ptr->next;
}
}
It travels across the LinkedList and prints all the elements.
#include <iostream> using namespace std; struct Node { int data; Node* next; }; class Stack { Node* top; public: Stac...
No comments:
Post a Comment