Monday, November 1, 2021

Linked List Data Structure

 using namespace std;
#include<iostream>
class Node {
public:
    int Value;
    Node* Next;
};

void print_node(Node* n) {
    while (n!=NULL) {
        cout << n->Value << endl;
        n = n->Next;
    }
}


int main() {

    Node* head = new Node();
    Node* second = new Node();
    Node* third = new Node();

    head->Value = 1;
    head->Next = second;

    second->Value = 2;
    second->Next = third;
    
    third->Value = 3;
    third->Next = NULL;

    print_node(head);


    system("pause > 0");
    return 0;
}

No comments:

Post a Comment

Priority queue deleting elements after ascending inputs Gaand Fadd

 using namespace std; #include<iostream> #define N 5 class pq { public:     int* arr;     int front;     int rear;     pq() {         ...