Quiz-1

Hello PrepSter,

If you find any errors in the quiz below kindly comment in the comment section and we will make it our priority to fix it.

Also if you have a better of the solution to the questions, please do comment them below and if we find it better than ours, we will post it in our website.

Question 1

Time: 00:00:00
 What is an external sorting algorithm?

Algorithm that uses tape or disk during the sort

Algorithm that uses tape or disk during the sort

Algorithm that uses main memory during the sort

Algorithm that uses main memory during the sort

Algorithm that involves swapping

Algorithm that involves swapping

Algorithm that are considered ‘in place’

Algorithm that are considered ‘in place’

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
 What is an internal sorting algorithm?

Algorithm that uses tape or disk during the sort

Algorithm that uses tape or disk during the sort

Algorithm that uses main memory during the sort

Algorithm that uses main memory during the sort

Algorithm that involves swapping

Algorithm that involves swapping

Algorithm that are considered ‘in place’

Algorithm that are considered ‘in place’

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What is the worst case complexity of bubble sort?

O(nlogn)

O(nlogn)

O(logn)

O(logn)

O(n)

O(n)

O(n2)

O(n2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Select the appropriate code that performs bubble sort.

for(int j=arr.length-1; j>=0; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }

for(int j=arr.length-1; j>=0; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }

for(int j=arr.length-1; j>=0; j--) { for(int k=0; k

for(int j=arr.length-1; j>=0; j--) { for(int k=0; k

for(int j=arr.length; j>=0; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }

for(int j=arr.length; j>=0; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What is the average case complexity of bubble sort?

O(nlogn)

O(nlogn)

O(logn)

O(logn)

O(n)

O(n)

O(n2)

O(n2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
 What is the advantage of bubble sort over other sorting techniques?

It is faster

It is faster

Consumes less memory

Consumes less memory

Detects whether the input is already sorted

Detects whether the input is already sorted

All of the mentioned

All of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array?

4

4

2

2

1

1

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
How can you improve the best case efficiency in bubble sort? (The input is already sorted)

boolean swapped = false; for(int j=arr.length-1; j>=0 && swapped; j--) { swapped = true; for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; swapped = false; } } }

boolean swapped = false; for(int j=arr.length-1; j>=0 && swapped; j--) { swapped = true; for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; swapped = false; } } }

boolean swapped = true; for(int j=arr.length-1; j>=0 && swapped; j--) { swapped = false; for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }

boolean swapped = true; for(int j=arr.length-1; j>=0 && swapped; j--) { swapped = false; for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }

boolean swapped = true; for(int j=arr.length-1; j>=0 && swapped; j--) { swapped = false; for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; swapped = true; } } }

boolean swapped = true; for(int j=arr.length-1; j>=0 && swapped; j--) { swapped = false; for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; swapped = true; } } }

boolean swapped = true; for(int j=arr.length-1; j>=0 && swapped; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; swapped = true; } } }

boolean swapped = true; for(int j=arr.length-1; j>=0 && swapped; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; swapped = true; } } }

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
 What is the best case efficiency of bubble sort in the improvised version?

O(nlogn)

O(nlogn)

O(logn)

O(logn)

O(n)

O(n)

O(n2)

O(n2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array with improvised version?

4

4

2

2

1

1

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]