0% found this document useful (0 votes)
2 views2 pages

Linked_List_Types_Notes

The document outlines four types of linked lists: Singly Linked List, Doubly Linked List, Circular Singly Linked List, and Circular Doubly Linked List. Each type is defined and includes a basic C++ implementation with class structures and methods for inserting, deleting, and displaying nodes. The document serves as a guide for understanding linked lists and their implementations in C++.

Uploaded by

White Devil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Linked_List_Types_Notes

The document outlines four types of linked lists: Singly Linked List, Doubly Linked List, Circular Singly Linked List, and Circular Doubly Linked List. Each type is defined and includes a basic C++ implementation with class structures and methods for inserting, deleting, and displaying nodes. The document serves as a guide for understanding linked lists and their implementations in C++.

Uploaded by

White Devil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linked Lists: Types and C++ Implementations

1. Singly Linked List

Definition:
A linear data structure where each node points to the next node.

Code (Basic Operations):


class Node {
public:
int data;
Node* next;
Node(int val) { data = val; next = nullptr; }
};

class SinglyLinkedList {
Node* head;
public:
SinglyLinkedList() { head = nullptr; }
void insertFront(int val) { ... }
void insertEnd(int val) { ... }
void deleteNode(int val) { ... }
void display() { ... }
};

2. Doubly Linked List

Definition:
Each node points to both the next and previous node.

Code:
class Node {
public:
int data;
Node* prev;
Node* next;
Node(int val) { data = val; prev = next = nullptr; }
};

class DoublyLinkedList {
Node* head;
public:
DoublyLinkedList() { head = nullptr; }
void insertFront(int val) { ... }
void insertEnd(int val) { ... }
void deleteNode(int val) { ... }
void displayForward() { ... }
void displayBackward() { ... }
};
Linked Lists: Types and C++ Implementations

3. Circular Singly Linked List

Definition:
Last node points back to the first node.

Code:
class Node {
public:
int data;
Node* next;
Node(int val) { data = val; next = nullptr; }
};

class CircularSinglyLinkedList {
Node* head;
public:
CircularSinglyLinkedList() { head = nullptr; }
void insertEnd(int val) { ... }
void deleteNode(int val) { ... }
void display() { ... }
};

4. Circular Doubly Linked List

Definition:
Last node points to the first and first node points to the last.

Code:
class Node {
public:
int data;
Node* prev;
Node* next;
Node(int val) { data = val; prev = next = nullptr; }
};

class CircularDoublyLinkedList {
Node* head;
public:
CircularDoublyLinkedList() { head = nullptr; }
void insertEnd(int val) { ... }
void deleteNode(int val) { ... }
void displayForward() { ... }
};

You might also like