Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: goo.gl/HIB0wL
sir your video are literally worth enough ..!!apart from this your knowledge your gesture your way of explanations set the platform to different level..!! hands up to u sir👏👏
Sir, Please upload All sorting programs Sir, I am a great fan of yours teaching. I studied C from you in Ameerpet and studying data structure from youtube... Please...Uploading all sorting programs.ASAP as it great time for us in Bangalore to get a job.
very nice explanation could you please post reverse double linked list and tress like BST,AVL tress operations,hashing also iam looking for your posts please post ASAP
Respected Sir I have understood very well but having problem in printing the reverse linked list how to print it can you please explain in text or any other way I'll be very thankful to you
We r taking the p pointer to pointer to next node..and q pointer to point to the previous node (u can see q node in inner while loop)..i mean in order to swap all elements of linkes list we have to make the p pointer to point to next node and q pointer point to previous node... Hope u got clarify man. Happy coding😉
this is a BAD implementation to reverse single linked list! Because there is a great overhead when swapping the data of 2 nodes, and the time complexity is O(n^2) because you have to access linked list each time when going to the position j ! Besides, you can Google for a best solution, maybe it's about O(n) time and just swap the pointer but not the data!
Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: goo.gl/HIB0wL
sir how is the arrow link is working , link is not pointing to anything in the program!!!
sir your video are literally worth enough ..!!apart from this your knowledge your gesture your way of explanations set the platform to different level..!! hands up to u sir👏👏
You are an excellent teacher sir , you clear the concepts so well . So glad i found this channel.
That was excellent .. I went through so many videos to get the concept and honestly this was the best...
u r great sir...make tough pblm very easy
I am not tired of to comment on your every vedio ,👍👍👍
Sir your video is worth watching .. Never had such clear conception ... a thank you wont be enough !
Love and respect form Bangladesh ! You are an awesome teacher Sir !
Sir, your explanation is great! I am very thanks full to you.
HERE IS THE COMPLETE CODE: It includes all functions of linked list tought in this channel. To watch the code of only this video, Please see the void reverse() function only:
#include
#include
struct node
{
int data;
struct node* link;
};
struct node* root = NULL;
int len;
void append();
void addatbegin();
void addatafter();
int length(void);
void display();
void delete();
void reverse();
void main()
{ int ch;
while(1)
{
printf("Single linked list operations are:
");
printf("1.Append
");
printf("2.AddAtBegin
");
printf("3.AddAtAfter
");
printf("4.length
");
printf("5.delete
");
printf("6.display
");
printf("7.Reverse
");
printf("8.Exit
");
printf("enter your choice: ");
scanf("%d",&ch);
printf("Your choice was: %d
",ch);
switch(ch)
{
case 1: append();
break;
case 2: addatbegin();
break;
case 3: addatafter();
break;
case 4: len = length();
printf("length is %d
",len);
break;
case 5: delete();
break;
case 6: display(root);
break;
case 7: reverse();
break;
case 8: exit(0);
default : printf("invalid input
");
}
}
}
void append()
{
struct node* temp;
temp=(struct node*)malloc(sizeof(struct node));
printf("Enter node data
");
scanf("%d",&temp->data);
temp->link=NULL;
if(root==NULL)
{
root= temp;
}
else
{
struct node* p;
p=root;
while(p->link!=NULL)
{
p=p->link;
}
p->link=temp;
}
}
void display(struct node* temp)
{
if(temp==NULL)
{
printf("list is empty
");
}
else
{
printf("elements are: ");
while (temp != NULL)
{
printf(" %d ", temp->data);
temp = temp->link;
}
}
printf("
");
}
int length()
{
struct node* temp;
int count=0;
temp=root;
while(temp!=NULL)
{
count++;
temp=temp->link;
}
return count;
}
void addatbegin()
{
printf("to be build
");
}
void addatafter()
{
struct node* temp;
int loc;
printf("Enter location after which, node to be inserted:
");
scanf("%d",&loc);
if(loc>length())
{
printf("invalid input position:
");
printf("current list is having %d nodes only",length());
}
else
{
int i=1;
struct node* p=root;
while(ilink;
i++;
}
temp=(struct node*)malloc(sizeof(struct node)); //new node creation
printf("enter new node data:
");
scanf("%d",&temp->data);
temp->link=NULL;
//now just link this new node
//first make right connection
temp->link=p->link; //right connection
p->link=temp; // left connection
}
}
void delete()
{
struct node* temp;
int loc;
printf("Enter node number to be delete: ");
scanf("%d",&loc);
if(loc>length())
printf("invalid position input
");
else if (loc==1)
{
temp=root;
root=temp->link;
temp->link=NULL;
free(temp);
}
else
{ int i=1;
struct node* p=root;
struct node* q=p;
while(ilink;
i++;
}
q=p->link;
p->link=q->link;
q->link=NULL;
free(q);
}
}
void reverse()
{
struct node* p=root;
struct node* q=root;
int i=0,temp, j=length()-1;
while(idata;
p->data=q->data;
q->data=temp;
p-p->link;
q=root;
i++;
j--;
}
}
very thank you. can u give me book name (or website) of this code. for learn more.
its not optimised.(w.r.t interview)
I watched ur complete playlist...that's really helpful for fresher students
Simple and to the point Naresh!
very,very,,,,,,,nice sir your videos your explanation morvelessss
Sir, u have given us a wonderful explanation
Sir can u explain merging of two linked lists please sir
Sir, Please upload All sorting programs
Sir, I am a great fan of yours teaching. I studied C from you in Ameerpet and studying data structure from youtube...
Please...Uploading all sorting programs.ASAP as it great time for us in Bangalore to get a job.
Easy to understand ..Thank you
Sir nijamga mi antha clear ga evaru cheypaleru miku Nijam ga johar entha cheypina takuvey sir mi gurunchi
Sir you are awesome..😄😄
fabulous explanation.
thank u so much this is life saviiing man
Sir your lectures are best
Thank you sir very great explainanation
very helpful for me
Me 2..😄😉
More helpful video, sir.tq
U r amazing sir!!!! :)
Sir please upload the video about addition of two polynomial
God of Data Structure
Thank You
tq sir ,clear expalnation
Pass kra diya bhaishab aapne
Thanks👌
good xplanation
Best explanation
Instead of reinitialising q we can add j-i in the while loop. I guess it computes to the same
Thank you so much sir!
Sir will you please explain reversing singly linked list elements along with there corresponding addresses.
This magic happens in the time complexity at the order of N square.
Yes time complexity is expirational time rather than using swapping method he should have been using 3 pointers.....
Sir , in case of implementing the reverse linked list , why length is used?
to calculate the value of j
Thank u sir
Good explanation sir
Thank you sir..
Tqqqqq. Sir
sir what about the time complexity of the code given?
sir plzz implement all logics in pc or laptop sir
very nice explanation could you please post reverse double linked list and tress like BST,AVL tress operations,hashing also iam looking for your posts please post ASAP
sir,u are initially choosing the elements in increasing order.so in case of reversing swapping helps.what if the elements are not sorted
@Aditya Darade no i was saying that to avoid problem sir intentionally choosed sorted elements and that helped in reversing.
@Aditya Darade what if initially the chosen elements are not sorted.?
reversing or swapping is not done on the basis of node data,its based on there position(address). Here we did not interfere with node data.
Awesome
Sir ,can you show how will you create struct Node in which you can store the root and pointers and also best and worst cases!
Thanks!
just awesome
i wish you were using java :( but i liked your videos :) please make videos in data structure in java.
thank u
awesome video sir but you didnt define the variable k
sir what we do when eleemnt in array is 5
if u swap 0with4 and 1wit3 and then which elemet weselect to swap wit loc 2 element
at time of loc 2, I=j=2 and as in while loop (I
One question, I thought root will point to last node in the linked list and address will be reversed.
Hi Saurav,
Check this
Full Playlist of Data Structure
Explained very easily
th-cam.com/video/gh9siMkdLkM/w-d-xo.html
Sir, can't we take i=1 and j=len??
Please explain other topics of data structures
good Sir
Super
Isnt this algorithm O(N2)?
Guess so
Sir, I executed the code but reverse order of linked list is not coming perfectly..it is reversing in inorder sir, please help me in this anybody
sir, i need to learn data structures completely but i did not find data structures in online training
Respected Sir
I have understood very well but having problem in printing the reverse linked list how to print it can you please explain in text or any other way I'll be very thankful to you
make the videos on data structure using java, please
👏👏
Sir please explain how i become 0 and J become 3
plzz implement all operations in laipi sir
What happens if the array consists 7 elements
Sir, don't we need to reverse the link part too?
No need. We should not care about the link (Adrees of next node which we can't predict). It's only the matter is the data (elements)
Reverse function can be written simpler by changing only links
Jacek Soplica I
K variable is not declared. And temp pointer variable also.
and we need to create a local variable temp by using "struct node* temp"
We need to declare temp as int type ..not struct node* because it is Storing int type data
Sir why there is nested while , I can't get that can any one please explain me
The first while loop is used for increasing i and decreasing j until i
Sir u mistakenly explained as I=0 and j=4 after first iteration actually it's I=1 and j=3
🙏🙏🙏🙏
complete this playlist and arrange videos in correct manner
Sir why you are writing after i++ and j--
P P.data
Q root
Pls explain sir😔😔
learn pointers, Structures and then watch all the videos from this playlist, you will know. In short it is a structure member
We r taking the p pointer to pointer to next node..and q pointer to point to the previous node (u can see q node in inner while loop)..i mean in order to swap all elements of linkes list we have to make the p pointer to point to next node and q pointer point to previous node...
Hope u got clarify man.
Happy coding😉
for this method, it is mandatory that the list should be arranged in ascending order first otherwise it fails
It is all done by loop's .
Actually we Traverse lists via loop
how 'i' value is 0 and 'j' value is 3 at 14:12 min
'i' will be incremented and 'j' will be decremented right,? then i=1 and j=3 is correct
yes,u are correct
He should have basically said that k =0 instead of i.
this is a BAD implementation to reverse single linked list! Because there is a great overhead when swapping the data of 2 nodes, and the time complexity is O(n^2) because you have to access linked list each time when going to the position j ! Besides, you can Google for a best solution, maybe it's about O(n) time and just swap the pointer but not the data!
Hats off
Why k is used
All the program implementations are available here :)
houseofgeek.in/single-linked-list-operations/
Explanation is good . But solution is not efficient ,space and time complexity will be more.
Radix sort
//all sll oprations
#include
#include
using namespace std;
struct node{
int data;
node *next;
};
struct node *temp,*temp1,*head,*tem;
int len=0;
//head=NULL;
void insertatend(){
temp=new node;
int e;
coute;
temp->data=e;
temp->next=NULL;
if(head==NULL){
head=temp;
}
else{
temp1=head;
while(temp1->next!=NULL){
temp1=temp1->next;
}
temp1->next=temp;
}
}
void display(){
if(head==NULL){
coutnext;
temp->next=tem;
}
}
void delet(){
int pos;
coutpos;
if(head==NULL){
coutnext=tem->next;
free(tem);}}
int length(){
temp=head;
while(temp!=NULL){
len++;
temp=temp->next;
}
return len;
}
void reverse(){
int i=0;
int j=length();
node *p,*q;
//p=new node;
//q=new node;
p=head;
q=head;
int t,k;
while(idata;
p->data=q->data;
q->data=t;
i++;
j--;
q=head;
p=p->next;
}
cout
sir all things are good but sir you didn't reversed middle element
Middle elements stay at middle only
You are saying arrays
Heap sort
Not effective in terms of complexity, sorry can't agree
it was so hard
I dont think so..🙄🙄
Not efficient n optimized algo
not effective program . time complexity will be n^2 for it .
can you can give an alternative to it if yes then do
Super