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.

    Sources

    http://www.patheos.com/blogs/hallq/2014/06/so-youre-thinking-of-applying-to-app-academy

    Algorithm




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

    Become a Premium Member

    With our large collection of challengs, tutorials, and solutions, we make it easy for you to become a better coder, prepare for interviews, and learn new skills from more experienced coders.

    “I have my final coding interview with Fullstack Academy tomorrow, and Coderbyte has been an invaluable tool to help me progress as a
    developer.” ― Josh Aharonoff
    • 200+ Coding Challenges
    • Mock Interview Questions
    • 500,000+ Code Solutions
    • Algorithm Tutorials
    • Interview Prep Courses
    mrdaniel published this on 11/24/15 | javascript, bootcamp, array, sorting, App Academy
    Comments
  • +
  • 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);
                    Console.WriteLine(str);
            }
    
    
    Login to submit a comment