![]() |
Bubble sort and Headp Sort
Hello all expert C and C++ programmer, i truly new to programming.
1. I have coded the bubble sort but i cannot sort it in ascending order. Below is my code: Code:
#include<iostream>Code:
#include<iostream>2. Can u explain to me the heap sort algorithm ? What is siftdown ? Thanks for your help. Your help is greatly appreciated by me and others. |
Re: Bubble sort and Headp Sort
By this time you should be aware what is an article and you should not be submitting your queries as articles. As of now I have moved them in the forum for discussion.
|
Re: Bubble sort and Headp Sort
Sorry for my blind eye. Thanks shabir.
|
Re: Bubble sort and Headp Sort
Your array only has a few items. If you will go through your algorithm with pencil and paper, you will discover your problem.
A heap siftdown is the method for restoring the heapness of the tree after the root has been removed. |
Re: Bubble sort and Headp Sort
Finally, i have understand the algorithm.
Basically, the outer_loop has enforce the inner loop to loop again and again until the array is sorted. Below is the code: Code:
void bubbleSort(int sequence[], int size)Imagine this case. I hope this code and algorithm help others. |
| All times are GMT +5.5. The time now is 03:08. |