ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
#include #include struct node{ int value; struct node *next; struct node *left;};struct node *newnode, *head = NULL, *temp;void create(){ int num = 1; while(num) { newnode = (struct node*)malloc(sizeof(struct node)); printf("enter new node value "); scanf("%d",&newnode->value); newnode->next = NULL; newnode->left = NULL; if(head == NULL) { head = newnode; } else { temp = head; while(temp->next != NULL) { temp = temp->next; } temp->next = newnode; } printf(" do you want to create mode node 1 for yes and 0 for no "); scanf("%d",&num); }}void display(){ if(head == NULL) { printf("double linked list is empty "); } else { temp = head; while(temp != NULL) { printf("%d=>",temp->value); temp = temp->next; } }} void sort() { struct node *i, *j; int num; for(i = head; i->next != NULL; i=i->next) { for(j=i->next; j != NULL; j=j->next) { if(i->value > j->value) { num = j->value; j->value = i->value; i->value = num; } } } }int main(){ create(); display(); printf("sorted doubly linked list"); sort(); display(); return 0;}
is this selection sort?
@@maharaniputrisuari8783 bubble sort
Thank you so much for the code and explanation and the execution.....................
You can checkout other codes too. I try to cover most of the code that was the part of Data structure and Algorithms part
You can also check out the project playlist section
great brother keep it up😊
Thank you so much 😀
Thanks
Welcome
#include
#include
struct node
{
int value;
struct node *next;
struct node *left;
};
struct node *newnode, *head = NULL, *temp;
void create()
{
int num = 1;
while(num)
{
newnode = (struct node*)malloc(sizeof(struct node));
printf("enter new node value
");
scanf("%d",&newnode->value);
newnode->next = NULL;
newnode->left = NULL;
if(head == NULL)
{
head = newnode;
}
else
{
temp = head;
while(temp->next != NULL)
{
temp = temp->next;
}
temp->next = newnode;
}
printf(" do you want to create mode node 1 for yes and 0 for no
");
scanf("%d",&num);
}
}
void display()
{
if(head == NULL)
{
printf("double linked list is empty
");
}
else
{
temp = head;
while(temp != NULL)
{
printf("%d=>",temp->value);
temp = temp->next;
}
}
}
void sort()
{
struct node *i, *j;
int num;
for(i = head; i->next != NULL; i=i->next)
{
for(j=i->next; j != NULL; j=j->next)
{
if(i->value > j->value)
{
num = j->value;
j->value = i->value;
i->value = num;
}
}
}
}
int main()
{
create();
display();
printf("sorted doubly linked list
");
sort();
display();
return 0;
}
is this selection sort?
@@maharaniputrisuari8783 bubble sort
Thank you so much for the code and explanation and the execution.....................
You can checkout other codes too. I try to cover most of the code that was the part of Data structure and Algorithms part
You can also check out the project playlist section
great brother keep it up😊
Thank you so much 😀
Thanks
Welcome