2.5 Insertion of a Node in Linked List(at Beginning,End,Specified Position)with Code | DSA Tutorials
HTML-код
- Опубликовано: 15 сен 2024
- Jennys Lectures DSA with Java Course Enrollment link: www.jennyslect...
In this video we will see how to Insert a node in linked list - at beginning, at end and at any given position with example. we will also write a C program for insertion operation.
DSA Full Course: https: • Data Structures and Al...
******************************************
See Complete Playlists:
C Programming Course: • Programming in C
C++ Programming: • C++ Complete Course
Python Full Course: • Python - Basic to Advance
Printing Pattern in C: • Printing Pattern Progr...
DAA Course: • Design and Analysis of...
Placement Series: • Placements Series
Dynamic Programming: • Dynamic Programming
Operating Systems: // • Operating Systems
DBMS: • DBMS (Database Managem...
*************************************************
Connect & Contact Me:
Facebook: / jennys-lectures-csit-n...
Quora: www.quora.com/...
Instagram: / jayantikhatrilamba
#datastructurenotes
#whatislinkedlist
#insertioninlinkedlist
#algorithms
#dsa
You are one of the finest teachers .
I am completing my data structure subject as I am in Computer Engineering 2nd year , by watching your all the videos by sequentially to not to miss any concepts. And I am getting all the concepts very clearly and undoubtedly
I would just like to say Thank you very much for all these video lectures .
Thank you very very much Jenny Ma'am 🙏✌
are you placed now bro?
@@celebratinglife803 mai bhi yhi puchhne vala tha😂😂
@@celebratinglife803 🔥😂
Ma'am, This is the best channel on RUclips followed by NESO academy , l have encountered so far. Thank you kindly for your explanations.
Neso academy 💪🙏
Saurabh shukla sir
@@Mojit00 absolutely 💯
But in terms of thus DSA, this chnnel is better than neso academy too
Hello Jenny ma'am, I really want to appreciate your efforts for teaching us ad giving exactly the same feeling of learning in a class. I am a software engineer with electronics engineering background. Your lesson are really helping me to understand fundamentals and motivates me that I can also understand data structure and algorithms. Thank you so much ma'am. 🤗🙏
Just subscribed to her! I'll pass my college years watching her videos. Love from Brazil!
You cleared all my doubts about linked list. I was trying to understand the concept from a week. At last your video helped a lot, thank you so much. May god bless you ❤❤
Mam you are really prove a God for me. I searched this topic from different sources but no one could explained like you. Really great mam 🙏
ma'am please make more video. like - stack, tree, recursion, interview question, leetcode solution etc.
You are great teacher
yes mam
Yes ma'am
9:16 : code for beginning
17:00 : code for end
26:00 : code for after given location
thanks a lot !
Thanks
Hii mam,
Very clear explanation of Insertion and deletion mam
Words can't describe how i am mad about you lectures becoz now the time is 12:47 am without using any social media i watched this video completely.
Thanks form the bottom of my Heart
May the Almighty gives you a Healthy and wealthy life...!
Amazing! Explained with all the minute details. A lot of people get confused about when to use temp != 0 or temp->next != 0, explained in detailed at: 15:48
Sir where should write this insert at beginning code in the linked list code
You are an awesome teacher mam ... Your lecture make me feel like that I can do anything ... Thank you so much mam we love you ❤️.. the way you teach is the best ❤️
This is the final code i wrote including creating ,print and insertion in Linked List.
#include
#include
struct node
{
int data;
struct node *next;
};
struct node* head=NULL;
struct node* newNode;
struct node* temp;
int Number;
void Print(){
temp=head;
printf("[");
while(temp!=0){
printf("%d " ,temp->data);
temp= temp->next;
}
printf("]");
}
void createLinkedList(){
//int Number;
printf("Enter the number of data you want to enter: ");
scanf("%d", &Number);
for(int i=0; idata);
newNode->next=NULL;
if(head==NULL){
head=temp=newNode;
}
else{
temp->next= newNode;
temp=newNode;
}
}
Print();
}
void insertatbegin(){
int newData;
printf("
Enter the data you want to add: ");
scanf("%d" , &newData);
newNode= (struct node*) malloc(sizeof(struct node));
newNode->data= newData;
newNode->next= head;
head= newNode;
Print();
Number++;
}
void insertatend(){
int dataEnd;
newNode= (struct node*) malloc(sizeof(struct node));
printf("
Enter the data you want to insert at end: ");
scanf("%d" , &newNode ->data);
newNode-> next= 0;
temp=head;
while(temp->next!=0){
temp= temp->next;
}
temp->next= newNode;
Print();
Number++;
}
void insertatspecific(){
int pos;
int i=1;
printf("
Enter the position you want to insert data: ");
scanf("%d" , &pos);
if(pos>Number){
printf("Invalid position");
}
else{
newNode= (struct node*) malloc(sizeof(struct node));
temp=head;
while(inext;
i++;
}
printf("Enter the data: ");
scanf("%d" ,&newNode->data);
newNode->next= temp->next;
temp->next=newNode;
Print();
}
}
int main() {
createLinkedList();
insertatbegin();
insertatend();
insertatspecific();
return 0;
}
Is this working?
Teachers like you are the reason why we pass university exams 😍😍😍
"pass with good marks"
Hats off to you Mam...Your teaching is the best..I was having very tough time in studying data structures but your videos made it very easy to study..Thank You So Much Mam🙏🏻..
Mam i understand this concept!! your the best teacher of data structure plzzz make video on different chapter of data structure and other data structure subject 🙏🏻👍🏻✨
You're*
You have been the life saver for most of us. THANK YOU VERY MUCH😍😍
Ohhh , just wow . Maam the quality content you are creating you must have 1million subs. Just loved the way you explain everything.
Mam....i have started just ur DSA part..and its really really awesome....by handwritten its quite simple to understand and ur teaching methods are outstanding...one by one line and how the code actually run ....oh my god..i m a big fan of your mam......alots of love to uh ❤❤...keep growing ...🎉❤
I can't thank Jenny ma'am enough for making each line and my concepts crystal clear 💙
I was not at all into data structures, I used to run away from this subject but now that I understand this I apply my own logic to perform these operations
May god bless you . You may live for 100 years.
God sent angel fallen to earth to save data structure victims
Only 100 years?
@@firstnamelastname3532 maybe more
I''m attending these classes at 01:00 AM ...
And I am going to watch the next video now only.
The one & only one reason is the kind of dedication & determination with which she is teaching...
GOD BLESS YOU!
BEST WISHES...💕💕
I have never studied linked list with that much interest...thank you so much mam😄
Mam insertion in specific position is wrong because in IF condition you have to take (i
check i
The way u delt with this kind of sensitive topics is absolutely amazing mam.. It is completely understandable and u r explainantion in each n every step.. Thanks mam.. Love from HYDERABAD ♥
I from SriLanka mdm
U are doing very well
With the help of you im going to face my data structure final exam thank you mam
I have seen u grow from 500 subscribers till this day congratulations 🎉
Speechless mam
🙏🙏
Concepts are extremely " 👌 "
What a session. All concepts related to insertion is clear in a single video only💯
Thank you Jenny :)
You have explained the concept in such a way that I am able to create, add node at beginning, end & at a particular position now.
i'm from EC background and our college never taught us DS. I've been struggling with linked lists from the past 4 months and these videos are utterly awesome!
Same here
Thank you so much mam.iam watching and learning these things from kerala .I am an mca student doing distant mca.very hard to study since we get no classes. This helped me lot.I am sure i will watch all your lectures on data structure and will share with my frnds in study center.
You have high potential to explain the course,I have never seen any one like you explain and try to easily understand the course.
Now this how a teacher should teach a subject.....but sadly all of us get some nobody with a shallow knowledge of the subject in our college to teach us our core subjects ....thank you mam for your hard work and helping us in understanding the concepts in great detail.....
Your way of explaining is "OUTSTANDING".
Thank you 🙏💕so much ma'am
I face too much problem at beginning but now everything is soo clear. All credit goes to mam's hardwork of us❤
Maam ur great, really these videos are really helpfull to understand concepts clearly
I really dont know how to thank you mam, you deserve all the thanks in the world. You should be a lecturer for lecturers. Mam, thanks endlessly. May God bless you
Mam, my pre semester exams are going on and your videos helped me a lot. You explained every concept so clearly and nicely that I understand every topic very easily.Thank you.
Mam your lectures helped and help me a lot it's not even enough to say thank you
You just saved my future lots of love from Somalia
Complete code :
#include
#include
// Function declaration
void at_beginning();
void at_end();
void at_position(int);
void display();
struct node
{
int data;
struct node *next;
};
struct node *head;
struct node *newnode;
struct node *temp;
;
// main()
int main()
{
int choice = 1;
head = 0;
int count;
int a;
while (choice)
{
newnode = (struct node *)malloc(sizeof(struct node));
newnode->next = 0;
printf("Enter the data you want to insert :
");
scanf("%d", &newnode->data);
if (head == 0)
{
head = temp = newnode;
}
else
{
temp->next = newnode;
temp = newnode;
}
printf("Do you want to continue (1/0)? : ");
scanf("%d", &choice);
}
temp = head;
while (temp != 0)
{
temp = temp->next;
count++; //-----> can be printed as length of the linked list
}
printf("Which operation do you want to perform ?
press 1 ----> insert at the beginning
press 2 ----> insert at the end
press 3 ----> insert at specific position
press 4 ----> To Display the Linked list
");
scanf("%d", &a);
switch (a)
{
case 1:
at_beginning();
display();
break;
case 2:
at_end();
display();
break;
case 3:
at_position(count);
display();
break;
case 4:
display();
break;
}
return 0;
}
void at_beginning()
{
temp = head;
newnode = (struct node *)malloc(sizeof(struct node));
printf("Enter the data for insert at the beginning :
");
scanf("%d", &newnode->data);
newnode->next = 0;
newnode->next = head;
head = newnode;
}
void at_end()
{
temp = head;
newnode = (struct node *)malloc(sizeof(struct node));
printf("Enter the data for insert at the end :
");
scanf("%d", &newnode->data);
newnode->next = 0;
while (temp->next != 0)
{
temp = temp->next;
}
temp->next = newnode;
}
void at_position(int count)
{
int pos, i = 1;
temp = head;
newnode = (struct node *)malloc(sizeof(struct node));
printf("Enter the data for insert at a position :
");
scanf("%d", &newnode->data);
newnode->next = 0;
printf("Enter the position where you want to insert :
");
scanf("%d", &pos);
if (pos count)
{
printf("Can't be modified
");
}
else
{
while (i < pos-1)
{
temp = temp->next;
i++;
}
newnode->next = temp->next;
temp->next = newnode;
}
}
// Printing the Linked list
void display()
{
temp = head;
printf("Your Linked list is :
");
while (temp != 0)
{
printf("%d\t", temp->data);
temp = temp->next;
}
}
awsome !!!
Hey, thanks a lot🤩
👍🏿
Thanks
If we insert at beginning or ending counter variable is not increased
In my class: what is linked list?? They have both data, and pointer variable to the next node... That's all class finished about linked list.
And here.... Linked list have 21 subtopics... I'm totally grateful for you mam.. Thank you so much
A complete program would allow beginners to comprehend the basics better....Anyways it was a great learning experience.❤
Yes I understand it very well ma'am
You are so great
We want teachers like u in our college
If u are not here today then I don't know how to cover in this topic
So thank you ma'am 😊 💓
Thanks a ton dear.
Understood the concept very welll!! Thankyou Ma'am.
What is like particularly about this video is just that you didn't add any ads in this video, since your some video have ads, but Ma'am you know this lecture is most important and students should not distract by ads, I like that best teaching and teacher ever.....thanks for giving free lectures.....
there is lot off confusion but i understand it by my self thnk you mem your lecture very helpful.
Yes me also ... i have also lot of confusion ...
@@rimpinag6346 email me I will solve ur confusion
Mam hotaa hai ✓
You are the best and finest of them all.
The step were so helpful and straight forward, I have understood what looked like gibberish to me.
"im not gonna teach you how to creat a node "
Few seconds later
"Malloc allocates memory dynamically and to create a node we need....." 😂
yea true ....but it will do no harm if she does a slight revision of the previous topic....i think she did a good job in explaining this concept...it was giving me a hard time
lol bro...everytime mam does that..but its good actually
we not understanding simplify your explanation
Mam,all lectures video of you are very good & It will help me to obtaining good mark in Data Structure ,Thank you
Great effort... Love from Bangladesh
Thankyou mam, i could now understand how linked lists worked. Thankyou for explaining it to me.
the best ever ever ever. thanks from kurdistan--iraq
The way u explained the insert after given position....mam u r doing lot to a students....it is priceless
Implementation in C language.
#include
#include
int main()
{
struct node
{
int data;
struct node *next;
};
struct node *head, *newnode, *temp;
head=0;
int choice;
while(choice)
{
newnode=(struct node*)malloc(sizeof(struct node));
printf("Enter the data: ");
scanf("%d",&newnode->data);
newnode->next=0;
if(head==0)
{
head=temp=newnode;
}
else
{
temp->next=newnode;
temp=newnode;
}
printf("Do you want to continue(0,1)?: ");
scanf("%d",&choice);
}
temp=head;
while(temp!=0)
{
printf("%d",temp->data);
temp=temp->next;
}
struct new
{
int data;
struct new*next;
};
struct new *begnode;
begnode=(struct new*)malloc(sizeof(struct new));
printf("Enter the element: ");
scanf("%d",&begnode->data);
begnode->next=head;
head=begnode;
temp=head;
while(temp!=0)
{
printf("%d",temp->data);
temp=temp->next;
}
}
thank you bro
Bro mera head =0 mera code run nhi kar
@@NikhilKumar-ih5lv( head ==0 ) kro Bhai you are assigning the value not comparing ...
While (Choice = = 1)
Plz convert it in c++
This woman is just fabulous.
keep going Ma'am.
You're just amazing
if( concept taught==by Jenny mam)
{
printf("Understood each concept"}
}
Thank you so much mam for such detailed explanation...
💯 well u missed the semicolon 😅
paheli bar linked list paar ke achha laga. thanks ma'am for explaining so simply and clearly. ✌💖💥
after description, please make complete program. cause it create difficulties for beginners
True
Very true
mam you are the gem who made my concept regarding linked list clear. Mother India is proud to have a daughter like you and we as the students are fortunate to have you as our teacher
Thanks madam,your lectures helped me a lot✨
Wow , at last I understood linked list creation, insertion and now will see deletion .
I have recommended Jenny's lecture to my all friends as online lecture that are like just reading ppt , not so effective.
Thanks mam 😊 & Happy Independence day in advance 💫
Happy Independence Day 😊
@@JennyslecturesCSIT hi mam your videos very use ful
thank you so much mam.. I watched amlost all videos of linked list available on youtube but finally i came to understand clearly on your videos.. thank you mam..
Cleared all my doubts thanks a lot ma'am ❤️
Thank u thank u so much jenny ma'am.....I hv understood link lists for many times but was not able to understand them.....It is because of u I hv understood this so easly........Ur hardwork can be seen in ur videos......
Very basic explanations .......which are easy to understand ........ur hardwork will pay u hard......thank u so much
Love ur videos maam
Hi i am from Gujarat .......ur is teaching amazing...... thank you for guideing for free
You forgot about "count" variable in 'insert after a given position'
ohhhh achaa ...
Seriously I'm bunking my mca class to see ur videos...ur extraordinary teacher
#include
using namespace std;
class node
{
public:
int data;
node *next;
node(int v)
{
data=v;
next=NULL;
}
};
node *temp,*newnode;
node *head=NULL;
class singly
{
public:
int val;
//creation of a singly linked list
void creation()
{
coutval;
newnode=new node(val);
if(head==NULL)
{
head=newnode;
temp=head;
}
else{
temp->next=newnode;
temp=newnode;
}
}
//displaying the data of a singly linked list
void display()
{
node *temp1;
temp1=head;
while(temp1!=NULL)
{
coutcount){
cout
I got the complete clarity that how to insert the nodes in all the 3 conditions...
Thankyou very much mam.....❤
i love your teaching style, makes everything so clear! thank you so much jenny
Yes mam really it is reasonable and reliable mam
Thanks for your marvellous pedagogy
When you are teaching I have written code for other two parts mam
Thank You very much once again and I'm beholden to you
wow i never thought my concept would clear in first time. Thank you soooooooooo much.
Yes mam I got the concept of insertion operation very well from your videos .Thank you mam for such awesome content.Take love from my side ❤❤
thnx mam to teach us in that way. u are a absolute perfect teacher. if u will open the online class then i will definitly join that class.
Thanks for the efforts to explain the Linked List concepts so clearly! You did a fantastic job!
Hey, u teaches us very well.No one can teach like u, I like ur teaching style. Keep it up ✌🏼
I don't even like writing coding stuff ,by seeing ur videos now I'm now automatically trying my own of writing code
Tq
Outstanding explanation mam.....i will watch the whole series of data structures ...because the way you explain makes concept easier 🙏🙏
Thanks Mam for teaching this topic. After going through your videos on this topic my concepts are clear. You are really doing hard work Mam. 😊👌👌
Thank you so much mam
I saw your singlely linked list video , i understood the concept very well. Then I try doubly linked list . I done it my self 🎉🎉🎉
hello mam, Your teaching skill is very nice. i have understood linked list. if before this i got your video now i very good in DS. You are doing very good work and it is very helpful for us. god bless mam huge respect for you..
keep teaching us..
You are the best teacher I have ever met. You are very beautiful. I love everything about you
If a person is passionate at coding, then he/she must follow ur utube class's.Ur videos really help a lot..
Your explanation is excellent mam ☺️. You explain each and every step clearly so that each nd every one of us understand that easily 🥺. Hats off to your efforts . Thank you so much for this information mam 🙂. I really appreciate you and respect you. Y don't these type of teachers exist in engineering colleges 😪?
I got it Ma'am. Truely speaking if I saw your videos in 2016 then I take CST in my diploma and then by default I am doing CSE btech now instead of Electrical Engineering.... I found my interested specialisation branch in Engineering in the prefinal year of btech for campass Placement....
Ma'am your videos are very helpful , they cleared all my doubts , your are doing a great job by helping us thank you ma'am for your support .
Your teaching style is very simple and easy to understand , you also clear the doubts which a student can have at the same time. Once again thank you and hat's off to you
Love u so much Dear ma'am
Watching from Kashmir !
A thanks would be less for you, Ma'am, we're so lucky to get this channel on this platform
you are helped in all the doubts in c programming continue doing this videos mam I love you way of explaining step by step mam I love u mam
Thanx ma'am you have cleared many concept of me about linked list.
Mam wonderful explanation I gonna never saw this type of explanation love you mam
Tanks for great explanation madam and your teaching skills is very well and so useful for present studying all computer students .
i was stuck on this topic and was waorried about the exam. thanks to you i am now feeling confident.
Please tell me
Why we shouldn't write
while (temp!=NULL)
for inserting node at Last
?
@@badrip3237 because if you write while(temp!=NULL) even after the temp assigned to last node while loop will contunie to process
so you will assign NULL to temp (temp=temp->next) which is we dont want to happen since we want temp to store the adress of last node not NULL
Mam , You are best.
I don't have much words, just want to say THANK YOU.
I'm electrical Engineering student basically But I don't know why I'm watching you Ma'am...... I don't know what you talking about, But I know one thing, May be God Creat you on Sunday With full relaxation 😍😍
Jenny mam you are great. Your teching style is very nice.thank you so much for explaing 😊
Great way of teaching.....we need teachers like you...