Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void bubbleSort(node *&h)
- {
- bool flag = true;
- while (flag)
- {
- node *p = h;
- node *k = NULL;
- flag = false;
- if (p->val > p->next->val)
- {
- node *tmp = NULL;
- swap(h, tmp);
- flag = true;
- }
- while (p->next->next != k)
- {
- if (p->next->val > p->next->next->val)
- {
- swap(h, p);
- flag = true;
- }
- p = p->next;
- }
- k = p;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement