Interview Questions

  • View all interview questions
  • blank
  • Implement bubble sort
    Implementing bubble sort is used as an example of a slightly harder problem that one should solve to be prepared for the App Academy bootcamp. The source link is listed below, but the statement was:
    I often use "implement bubble sort" (in a beginner-friendly language like Ruby or Python) as an example of one of the harder problems I had to do in order to get in to App Academy.
    We'll go ahead and implement bubble sort in JavaScript and Python below. Bubble sort is actually a very slow algorithm that one should never attempt to seriously use, but the algorithm is simple enough to implement which is why this question might be asked.



    You need to be a premium member to see the rest of this question and code.

    mrdaniel published this on 11/24/15 | javascript, bootcamp, array, sorting, App Academy
  • +
  • 0
  • -
  • Solution via C#:
            static void BubbleSort(ref int[] array)
                for (int i = array.Length - 1; i > 0; i--)
                    for (int j = 0; j < i; j++)
                        if (array[j] > array[j + 1])
                            Swap(array, j, j + 1);
            public static void Main(string[] args)
                    int[] array = { 8, 7, 6, 5, 3, 5, 1, 0 };
                    BubbleSort(ref array);
                    string str = string.Join(",", array);
    Login to submit a comment