100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary Insertion in Doubly Linked List(beginning, end, specific position) _ Data Structures

Rating
-
Sold
-
Pages
2
Uploaded on
22-04-2023
Written in
2022/2023

Insertion in Doubly Linked List(beginning, end, specific position) _ Data Structures

Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
April 22, 2023
Number of pages
2
Written in
2022/2023
Type
Summary

Subjects

Content preview

2.11 Insertion in Doubly Linked List(beginning, end, specific
position) | Data Structures
Jenny's Lectures CS IT
in this video we are going to see the insertion operation in doubly linked list insertion ad
beginning insertion at end insertion at any specific position as well as insertion after a given
position. In this video the data part three parts are there basically basically right we have already
discussed how to represent this node when you are going down a c program right and c in that
case we have n't maintained our tail pointer. In this case the insertion in doubly linked list at end
will take time order of 1 if you maintain this tail pointer. If you don't maintain this then only 3
nodes is there then this this this node and that head pointer you have to store. The drawback is
what this is going to take some memory space right. The list is a doubly linked list so we are
going to define a function you can say a create doubly-linked list right so first of all we're going
to create a node. The syntax we have already discussed many times right right Malik is a
function for dynamic memory allocation how much size you want size for this node.
We have asked from the user using this new printf and scanf the data inserted is 6 and here is 0
and 0 now I want to insert this node into this list so now if head is equal to 0 then in else part
what you will do now is insert a second node in that case the new node will contain 200. Intel
shows how you can exist this part both using head pointer and tail pointer. The same logic you
can apply after this it will ask you do you want to continue. If you press 1 then another a node
would be created and inserted if you press 0 then no extra node was created and only you can
call after that. The main motor is what have you can maintain this tail pointer so high hope you
got the concept now we are going to insert at beginning how you will write this function C so
now let us take this case we have these three node in the doubly linked list head is containing
150 and tail is containing the address of the last node that is 200.
How you can access this part the pointer to this node is head yes we have a pointer so we can
access all the three parts so here what you can write head of previous this part is previous is.
from where I can get this 500 this address in the new node we have 500 so is equal to new
node. how you can store this this this 500 here. Using a ten-pointer temp is pointing here then
here then then here and then finally temp will reach here after that using temp you can access
this part of the list. then you have to Trevor still here like we have discussed in singly linked list.
here we have maintained a tail pointer already right so no need to traverse the list we can
$7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
pranavnawandar

Also available in package deal

Get to know the seller

Seller avatar
pranavnawandar mahindra university
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
19
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions