Singly Linked list
// Node class to represent a node in a singly linked list
class Node {
public:
int data;
Node* next;
};
// Linked list class contains all the operations that can be performed on a singly linked list
class LinkedList {
public:
Node* head;
LinkedList() {
head = NULL;
}
// all the operations will be added here
// Print the list
void print() {
Node* temp = head;
while (temp != NULL) {
cout << temp->data << " ";
temp = temp->next;
}
cout << endl;
}
};Insert at Beginning
Time Complexity
Insert at End
Time Complexity
Insert at Index
Time Complexity
Delete from Beginning
Time Complexity
Delete from End
Time Complexity
Delete from Index
Time Complexity
Search
Time Complexity
Last updated