Insertion in a Doubly Linked List @prahladhacker #python #developer #javascript #java #html

Subscribers:
252
Published on ● Video Link: https://www.youtube.com/watch?v=FLrbDABNGUA



Duration: 0:13
3 views
2


Insertion in a Doubly Linked List
Follow @ghazi_it
Follow @ghazi_it
Follow @ghazi_it
Inserting a new node in a doubly linked list is very similar to inserting new node in linked list. There is a little extra work required to maintain the link of the previous node. A node can be inserted in a Doubly Linked List in four ways:

🔹At the front of the DLL.

🔹 In between two nodes

🔹After a given node.

🔹Before a given node.

🔹At the end of the DLL.

Insertion at the Beginning in Doubly Linked List:

To insert a new node at the beginning of the doubly list, we can use the following steps:

Allocate memory for a new node (say new_node) and assign the provided value to its data field.
Set the previous pointer of the new_node to nullptr.
If the list is empty:
Set the next pointer of the new_node to nullptr.
Update the head pointer to point to the new_node.
If the list is not empty:
Set the next pointer of the new_node to the current head.
Update the previous pointer of the current head to point to the new_node.
Update the head pointer to point to the new_node.

1. Add a node after a given node in a Doubly Linked List:
We are given a pointer to a node as prev_node, and the new node is inserted after the given node. This can be done using the following steps:

Firstly create a new node (say new_node).
Now insert the data in the new node.
Point the next of new_node to the next of prev_node.
Point the next of prev_node to new_node.
Point the previous of new_node to prev_node.
Point the previous of next of new_node to new_node.

Insertion at the End in Doubly Linked List:
Insertion_end_Doubly-Linked-List

The new node is always added after the last node of the given Linked List. This can be done using the following steps:

Create a new node (say new_node).
Put the value in the new node.
Make the next pointer of new_node as null.
If the list is empty, make new_node as the head.
Otherwise, travel to the end of the linked list.
Now make the next pointer of last node point to new_node.
Change the previous pointer of new_node to the last node of the list.
#programming #coding #programmer #python #developer #javascript #technology #code #java #coder #html #computerscience




Other Videos By Prahlad Hacker


2024-05-04wifi tool for termux without root [practical video]
2024-05-03Look like a hacker | Hacking | Wanna look like a hacker | hacking in PC | Hacking tools | #Shorts
2024-05-03ये है दुनिया का सबसे खतरनाक hacker | #shorts
2024-05-02Kisi bhi WiFi ka Password Kaise Pata Karen | How To Connect WiFi without Password 2023 WiFi password
2024-05-01How to hack a wifi Password With Kali Linux
2024-05-01Hack OTP Boom css and javascriptFollow @prahladsharma #css grid areas and #html5
2024-04-30Light using html css and javascriptFollow @prahladsharma #css grid areas and #html5
2024-04-29Learn Python 🔰 #programming #coding #programmer #python #developer #javascript #tech #programming
2024-04-29Padding vs margin CSS#html #css #java #javascript #fullstack #react #php #viralreels #Motivation
2024-04-293D tagcloud (HTML, CSS only) #code #frontend #development #programming #webdevelopment #htmlcss
2024-04-27Insertion in a Doubly Linked List @prahladhacker #python #developer #javascript #java #html
2024-04-26If you want to learn how to make animations like I’ll show you how.#visuals #discipline #animations
2024-04-26How To Make A Website With Login And Register | HTML CSS & JavaScript
2024-04-26🌟 Navigate Your Path in Frontend Development with This Roadmap #frontenddevelopment #webdevelopment
2024-04-26Rich vs. Wealthy #WorkHard #WorkSmart #Productivity #Efficiency #Success
2024-04-26what is Web Development #react #javascript #html #css
2024-04-25Learn and Earn...#trendingreels #trend #trendingsongs #motivation #html #react @prahladhacker
2024-04-25How To Create responsive login and registration form in html CSS& JavaScript in 2024
2024-04-23Navbar Animation program using computer graphics 🤠 #html #css #react #nodejs
2024-04-22HTML Input Types📢Follow for more amazing content and css trick.❤️
2024-04-13How To Make Working Contact Form With JavaScript | Receive Form Data On Email