Quiz: Take The Bubble Sort Algorithm Questions!

5 Questions | Total Attempts: 9704

SettingsSettingsSettings
Please wait...
Quiz: Take The Bubble Sort Algorithm Questions!

This quiz is to check your knowledge on Bubble sort algorithm.


Questions and Answers
  • 1. 
    What are the correct intermediate steps of the following data set when it is being sorted with the bubble sort? 15,20,10,18
    • A. 

      15,10,20,18 -- 15,10,18,20 -- 10,15,18,20

    • B. 

      10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20

    • C. 

      15,20,10,18 -- 15,10,20,18 -- 10,15,20,18 -- 10,15,18,20

    • D. 

      15,18,10,20 -- 10,18,15,20 -- 10,15,18,20 -- 10,15,18,20

  • 2. 
    In a bubble sort structure, there is/are?
    • A. 

      A single for loop

    • B. 

      Three for loops, all separate

    • C. 

      A while loop

    • D. 

      Two for loops, one nested in the other

  • 3. 
    What is the maximum number of comparisons if there are 5 elements in array x?
    • A. 

      10

    • B. 

      2

    • C. 

      5

    • D. 

      25

  • 4. 
    What is the max. number of comparisons that can take place when a bubble sort is implemented? Assume there are n elements in the array?
    • A. 

      (1/2)(n-1)

    • B. 

      (1/2)n(n-1)

    • C. 

      (1/4)n(n-1)

    • D. 

      None of the above

  • 5. 
    What are the worst case and best case time complexity of bubble sort consequently?
    • A. 

      O(n), O(n2)

    • B. 

      O(n2), O(n3)

    • C. 

      O(n), O(n3)

    • D. 

      None of the above

Back to Top Back to top