From ef872063ab01de443ed74a150d6c0accfe628131 Mon Sep 17 00:00:00 2001 From: Sneha Sadhu <146607813+sadhusneha3@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:37:40 +0530 Subject: [PATCH 1/2] Adding Insert at Starts of Singly Linked List --- .../Insert at Starts of Singly Linked List | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Linked List/Insert at Starts of Singly Linked List diff --git a/Linked List/Insert at Starts of Singly Linked List b/Linked List/Insert at Starts of Singly Linked List new file mode 100644 index 0000000..563f495 --- /dev/null +++ b/Linked List/Insert at Starts of Singly Linked List @@ -0,0 +1,41 @@ +I/P: 10->20->30->40 element=5 +O/P: 5->10->20->30->40 + +I/P: Null element=50 +O/P: 50 + +#include +using namespace std; + +struct Node { + int data; + Node* next; +}; + +Node* head = NULL; + +void insertAtBegin(int data) { + Node* newNode = new Node(); + newNode->data = data; + newNode->next = head; + head = newNode; +} + +void printList() { + Node* temp = head; + while (temp != NULL) { + cout << temp->data << " "; + temp = temp->next; + } +} + +int main() { + insertAtBegin(1); + insertAtBegin(2); + insertAtBegin(3); + insertAtBegin(4); + insertAtBegin(5); + cout << "Linked List: "; + printList(); + return 0; +} From 8a6221b1ecbe46681f03c893bb97c8cfb0c7d826 Mon Sep 17 00:00:00 2001 From: Sneha Sadhu <146607813+sadhusneha3@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:38:15 +0530 Subject: [PATCH 2/2] Rename Insert at Starts of Singly Linked List to Insert at Starts of Singly Linked List using C++ --- ...nked List => Insert at Starts of Singly Linked List using C++} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Linked List/{Insert at Starts of Singly Linked List => Insert at Starts of Singly Linked List using C++} (100%) diff --git a/Linked List/Insert at Starts of Singly Linked List b/Linked List/Insert at Starts of Singly Linked List using C++ similarity index 100% rename from Linked List/Insert at Starts of Singly Linked List rename to Linked List/Insert at Starts of Singly Linked List using C++