Search:

Type: Posts; User: iMalc

Search: Search took 0.10 seconds.

  1. Replies
    9
    Views
    5,561

    Here is an implementation of BubbleSort. void...

    Here is an implementation of BubbleSort.
    void BubbleSort(int a[], int n) {
    for (int i = n-1; i > 0; --i) {
    for (int j = 0; j < i; ++j) {
    if (a[j + 1] < a[j])
    std::swap(a[j], a[j + 1]);...
  2. Replies
    9
    Views
    5,561

    Any time your code is about to compare two items...

    Any time your code is about to compare two items you'll need to increment the count, much like you are in your "bubbleSort" function.

    But you have a more pressing problem to solve first. How do...
  3. Replies
    9
    Views
    5,561

    That's not bubble sort. Bubble Sort only swaps...

    That's not bubble sort. Bubble Sort only swaps adjacent items and as such an item gradually moves over until it is in place. Since you're not swapping adjacent items, it's actually just moving the...
Results 1 to 3 of 3