LINKED LIST (INSERTION AT BEGINNING,ENDING,SPECIFIED POSITION ) - DATA STRUCTURES
HTML-код
- Опубликовано: 11 сен 2024
- LINKED LIST INSERTION OF AN ELEMENT AT
1. BEGINNING
2. ENDING
3. SPECIFIED POSITION
INTRODUCTION TO LINKED LIST, CREATE AND DISPLAY
• LINKED LIST (CREATION ...
---------------------------------------------------------------------------------------------------------------
DATA STRUCTURES
• INTRODUCTION TO DATA S...
JAVA PROGRAMMING
• CORE JAVA TUTORIAL FOR...
COMPILER DESIGN
• INTRODUCTION TO COMPIL...
AUTOMATA THEORY || THEORY OF COMPUTATION
• INTRODUCTION TO AUTOMA...
R PROGRAMMING
studio.youtube...
HTML TUTORIALS WITH IMPLEMENTATION || LEARN HTML IN 4 HOURS
• HTML TUTORIALS WITH IM...
LEARN CSS IN 3 HOURS || CASCADING STYLE SHEETS FOR BEGINNERS
• LEARN CSS IN 3 HOURS |...
JAVA SCRIPT FOR BEGINNERS IN 7 HOURS || LEARN JAVA SCRIPT IN 7 HOURS || JAVA SCRIPT
• JAVA SCRIPT FOR BEGINN...
XML (eXtensible Markup Language)
• XML (eXtensible Markup...
OPERATING SYSTEM
• OPERATING SYSTEM
ETHICAL HACKING
• Video
VI EDITOR BASICS IN LINUX / UNIX || LEARN VI EDITOR COMMANDS || LINUX || UNIX
• VI EDITOR BASICS IN LI...
HOW TO DOWNLOAD & INSTALL MySQL IN WINDOWS 10
• HOW TO DOWNLOAD & INST...
DATABASE MANAGEMENT SYSTEM
• DATABASE MANAGEMENT SY...
PYTHON PROGRAMS
• PYTHON PROGRAMS
C PROGRAMMING
• 01 - VARIABLES & CONST...
CORE JAVA TUTORIAL FOR BEGINNERS || LEARN CORE JAVA IN 15 HOURS || JAVA TUTORIALS FOR BEGINNERS
• CORE JAVA TUTORIAL FOR...
PYTHON TUTORIALS FOR BEGINNERS (తెలుగు లో)
• Python in One Shot(తెల...
PYTHON OOPS - MODULES - EXCEPTION HANDLING (తెలుగు లో)
• PYTHON - OOPS CONCEPTS...
PYTHON NUMPY TUTORIAL IN TELUGU (తెలుగు లో) || COMPLETE NUMPY TUTORIALS IN TELUGU
• PYTHON NUMPY TUTORIAL ...
PYTHON PANDAS TUTORIAL IN TELUGU (తెలుగు లో) || COMPLETE PANDAS TUTORIALS IN TELUGU || DATA SCIENCE
• PYTHON PANDAS TUTORIAL...
MATPLOTLIB LIBRARY - PYTHON PROGRAMMING (ENGLISH)
• MATPLOTLIB LIBRARY - P...
PYTHON DATABASE CONNECTIVITY - MYSQL & MS-EXCEL
• PYTHON DATABASE CONNEC...
DATA STRUCTURES USING PYTHON (ENGLISH)
• DATA STRUCTURES USING ...
----------------------------------------------------------------------------------------------
Instagram : / sundeepsaradhikanthety
Sweat dripping off your neck is priceless for us.
Link list was very well explained i really liked it a lot.
I wrote the full program down here:
#include
#include
int value;
struct node
{
int data;
struct node *next;
}*new,*head,*tail,*temp,*current,*prev,*next;
void create()
{
new=(struct node*)malloc(sizeof(struct node));
printf("Enter the value:
");
scanf("%d",&value);
new->data=value;
new->next=NULL;
}
void insert()
{
create();
if(head==NULL)
{
head=new;
tail=new;
}
else
{
tail->next=new;
tail=new;
}
display();
}
void display()
{
printf("Updated link list is:
");
temp=head;
while(temp!=NULL)
{
printf("%d
",temp->data);
temp=temp->next;
}
}
void insertatbeg()
{
if(head==NULL)
printf("No Linked List found.");
else
{
create();
new->data=value;
new->next=head;
head=new;
display();
}
}
void insertatend()
{
if(head==NULL)
printf("No Linked List found.");
else
{
create();
new->data=value;
tail->next=new;
new->next=NULL;
tail=new;
display();
}
}
void insertatmid()
{
if(head==NULL)
printf("No Linked List found.");
else
{
create();
temp=head;
int pos,i;
printf("Enter the position where new node is to be inserted:
");
scanf("%d",&pos);
for(i=0;inext;
}
new->data=value;
new->next=temp->next;
temp->next=new;
display();
}
}
void deleteatbeg()
{
if(head==NULL)
printf("No Linked List found.");
else
{
temp=head;
head=head->next;
temp->next=NULL;
display();
}
}
void deleteatend()
{
if(head==NULL)
printf("No Linked List found.");
else
temp=head;
while(temp->next!=tail)
{
temp=temp->next;
}
temp->next=NULL;
tail=temp;
display();
}
void deleteatmid()
{
if(head==NULL)
printf("No Linked List found.");
else
{
temp=head;
int pos=0,i;
printf("Enter the position which you want to delete.
");
scanf("%d",&pos);
for(i=0;inext;
}
temp->next=temp->next->next;
display();
}
}
void count()
{ if(head==NULL)
printf("No Linked List found.");
else
{
int count=0;
temp=head;
while(temp!=NULL)
{
count++;
temp=temp->next;
}
printf("
Total number of nodes is : %d
",count);
}
}
void reverse()
{
if(head==NULL)
printf("No Linked List found.");
else
{
current=head;
while(current!=NULL)
{
next=current->next;
current->next=prev;
prev=current;
current=next;
}
}
head=prev;
display();
}
int main()
{
printf("Press:
1.Insert a new value.
2.Display all elements.
3.Insert at beginning.
4.Insert at End.
5.Insert in middle.
6.Delete at beginning.
7.Delete at End.
8.Delete in between.
9.Count total number of nodes.
10.Reverse
0.Exit");
int choice;
do
{
printf("
Enter your choice:
");
scanf("%d",&choice);
switch(choice)
{
case 1:
insert();
break;
case 2:
display();
break;
case 3:
insertatbeg();
break;
case 4:
insertatend();
break;
case 5:
insertatmid();
break;
case 6:
deleteatbeg();
break;
case 7:
deleteatend();
break;
case 8:
deleteatmid();
break;
case 9:
count();
break;
case 10:
reverse();
break;
case 0:
printf("Exited successfully");
break;
}
}while(choice!=0);
}
SWAPNIL JAISWAL bro apne tail ko traverse kiya he nhi na
Error is coming can you please help?
Send doubly linked list and circular linked list code
#include
sir your teaching is very understanding to students. iam also faculty,i v'l follow ur video. its very usefull to my teaching.
Thank u so much. The explanation is very simple. I hope it will be translated into Arabic🔥 in the future. Continue, u deserve the best 👌🏼
Sir if u don't mind can I correct the error in the last code that's means insertions of list at specific position in that ,, the for we had written is wrong ;; that is (i=0;i
but if we write pos code doesn't work!
Sir wla insert at specific position shi h ki nhi aur agr nhi h to dhi wla bhj dena
Ye insert at specific position shi Hain kya bro aur glt hai to shi wla bhj do
Insertion at ending 10:18
Insertion at specified position 14:28
So kind of u❤️
Since I only want to watch insertion at position
I think the loop will be (i=0;i
or i
@@supratimnayek2776 pos-1 coz you are initializing i to zero
Thank you so much sir,i can understand link list easily.
Sir need an implementation part..! U teach in very easy method, but still implementation would help us to understand more better...! Thanku
Yesss
tq sir it is very useful and i am a student of lbrce cse
Data structures is the important for the cse students
yes, it is very important to all those who are performing with the elements...And if you want to reduce the time complexity and memory occupation it will help you a lot
struct node{
int data;
struct node *next;//self referential pointer it points to itself useful for creating new nodes
};
int main(){
struct node *head=NULL,*tail=NULL,*new,*temp;//variables to acess our structure
int value;
char ch;
//node creation
do{
new=(struct node*)malloc(sizeof(struct node));//allocating the memory for our node
printf("enter any value: ");
scanf("%d", &value);
new->data=value;//assigning the value to node
new->next=NULL;//initially setting the 1st node to null
if (head==NULL){//condition1. checking if the list is empty if it is setting the node created as head and tail and next as null
head=new;
tail=new;
}else{//2.condition.if node already present linking the created node to tail and setting it as tail
tail->next=new;
tail=new;//setting new node as the new tail
}
//to check if the user wants to create another node
printf("do you want to continue to create another node if yes enter (y( if no enter (n): ");
scanf(" %c" , &ch); //inside of using fflushstdin leave some space before % symbol to avoid buffer memory
}while(ch=='y');
temp=head;
while(temp != NULL){
printf("%d" ,temp->data); //always use arrow not dot when aceesing a member in the structure which is of pointer
if (temp->next!=NULL){
printf("------>");
}
temp=temp->next;
}
//allocation memory
struct node *freePointer=head;
while (freePointer !=NULL){
struct node *nextNode=freePointer->next;
free(freePointer);
freePointer=nextNode;
}
return 0;
}
i really understand sir very very thanks from your teaching method
I'm in a right place...thanks sir
Sir I think in insertion at ending tail->next=new should come first followed by new->data=value and new->next=null.Correct me if I am wrong.
Yes,correct
@@dharanipriya2390 i think those 3 can be written in any order
Without execution its nothing!
that for loop of any position gives same result for both 0 and 1index ,so we should change it else if we wanted to insert at beginning or at index 1 with any position function will lead to same result ,i.e. insert at index 1
Best explanation 🙏🙏
Sir, I couldn't understand the statements written inside of for loop, in the case of specific position.. could explain it to me here in comment, it's quite confusing. It'll be a big help. Also the i value is not used in the body of loop, The iteration will happen only once so why? Please clarify my doubts, I the more I see the explanation in video the confused I get! Please help.
only the first statement is inside the for loop(that is why sir did not use parenthesis). The loop runs until we get to our desired position(pos-1)
@@farabimahbub5910insert at specific position algorithm shi h
Sir can we write this steps in algorithm on beginning,ending and specific position tell me sir plzzzzzzzzzz
Great video! Good job
TEACHING BETTER THAN IIT PROFESSORS. U ROCK SIR
you are the best sir
Best explanation 👍
Good explanation
really interesting class sir and nice understanding thank you sir
I think there is a mistake at entering a new node at a specified position can u clarify it for me???
I really appreciate your efforts♥
super explanation sir ,Thank you so much sir
thanks for a such easy way of understanding link list
Excellent👍
👏👏👏👏
Sir, please explain with program
U are explaining directly by assuming pointers
Many programs are available at websites
the trick is to learn the algo understand it ... then perform it using any language you want..
for me i like java and C#
Please anyone tell is this course is comleted and also for C langauge
thank you sir
Well explanation sir and thanku so much for this 👍👍🙏🙏
Super sir..u teaching nyc
Thank you so much sir
Excellent sir
Hai sir can we get some programs for this concept can we get some link
Sir u are too good.amazing
Sir initially there is no elements in list then how to insert a new element at begging
Applications of linked list topic pettandi sir
Do u still create test cases for insertion at specific positions? (i.e, it has to be part in the list.)
Thanks sir...very good explanation
Sir,I have a dought [if we want to create a array of 40 elements we run a for loop to reduce the size of the code and to save memory but when it comes to linked list if we want to create a linked list of 40 nodes then can't we use a for loop to create linked list so that we can reduce the size of the code]
why cant u use a for loop u definetly can use a for loop..!!!
Sir, for second iteration condition fails so how can we do?😢😢😢
Thanku sir I have a doubt that y we. Wrote POS -1 mean what
It is to get the correct position that is the new node will come after position 1,so the new node will be at position 2.
If we change the condition to i
Best explaination
sir malloc gives contiguous memory locations,why we are taking different adresses for each node , if we add new+size of struct node we will get right adress for another node they are contiguous na,
Sir please explain the program on single linked list
If we r moving temp to temp->next then why don't we use temp of prev ,for entering adress of new node to 1 position
Hai sir,
Linked list representation and Linear list representation, are both are same, if not what is the difference, can u explain sir?
Great
Sir at ending we can put any number suppose we can put 10 2000
types of linked lists explanation sir
Thnx a lot 👍
What's the difference between linked list and single linked list????
Thank you so much sir😊
👌
you are 1st
Sir while writing the code plz write on side what value,new,temp denotes it's a bit confusing
Are you from Machilipatnam
Yes
Nice classs sirrr
Thank You So much !!
sir this program not run in online gdb. suggest any ide other than turbo c.
will write algorthim for it sir,for better explanation
Sir kuch classes hindi me diya kro
❤❤❤
#include
#include
struct node
{
//Structure named node to store integer in variable data and a pointer variable which can store address location of next node
int data;
struct node *next;
}*head;
void insert(int data)
{
//This function will insert a new node to the start of the linked list
struct node *temp = (struct node*)malloc(sizeof(struct node));
temp->data=data;
temp->next=head;
head=temp;
}
void delete()
{
struct node *temp;
int loc,len,i=1;
printf("Enter the location");
scanf("%d",&loc);
struct node *p=head;
while(inext;
i++;
}
struct node *h=p->next;
p->next=h->next;
free(h);
}
void display()
{
struct node *temp=head;
if(temp==NULL)
{
printf("The list is empty");
}
else
{
while(temp!=NULL)
{
printf("%d->",temp->data);
temp=temp->next;
}
}
}
int main()
{
head=NULL;
insert(1);
insert(2);
insert(3);
insert(4);
insert(5);
insert(6);
display();
delete();
display();
return 0;
}
insertion at specific position value =34 but the position is 3
Thank You ❤️
Sir we are making *head and *tail variables but how will the compilor undersrtand that head is first element and tail is the last element ?
watch the previous video, we point to head to new(the first LL) and then don't change it, while changing the tail simultaneously as we add more nodes.
Tq soo much sir
What is the type of temp variable in specific insertion part
It is temporary variable.. we can't go with head always BECAUSE head always pointing first node of entire list .. so in order to tracking the nodes we have to use temp as temporary
Type of temp variable is STRUCT node same as head or tail
@@balakrishnana.k3293 you were not even answering wt he asked lol
how will the PC know what position is 2? we haven't assigned anything particular in order to calculate the length of LL
like in array indexing, the comp is able to know the indices of linked list as well. And indexing starts from 0.
sir please provide the full code
Thank you 🙏
sir intlo AC pettiyandi
great
Tnq sooo much sir
What is a Generalized Linked List
Trace the loop and explain that will be helpful its really confusion statements should be inside r outside the loop please clarify it...
Only one statement will be inside the loop ! The first statement!
Sir , insertion should not completely understand
Tq
Thanks
Thanks sir
Apka padhya smajh ni aa rha h sir ji
Why don't you write in the computer??
Sir say circular double linked also
Is datastructures in c and in python are same?
Stament should be in outside for loop???
just the first statement will be inside the loop(which is why he did not use any parenthesis)
Its obvious 😜!
Or pls share the code in description link
Head = new can you explain once sir
head points to new
Hai sir l want insert and delete linked list full program only plz sir
Sir meru Telugu valla
Yeah bro I think
Sir implementation
Please send the program
I suppose You should say "data of new" instead of "new of data"..🤔🤔
No its syntax is that way!!
data structue in java ho to link send kro plz.