# YOU CAN DOWNLOAD 200+ SUBJECTS PDF BOOK FOR COMPETITIVE EXAMINATIONS

## Timsort Multiple choice Questions and Answers (MCQs)

Question 11 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Which of the following algorithm is implemented internally in java when we use function arrays.sort()?

intro sort | |

quick sort | |

tim sort | |

merge sort |

Question 11 Explanation:

Java makes use of Tim sort internally for implementing arrays.sort(). It is mainly due to the fastness of this algorithm in comparison to other comparison based sorts.

Question 12 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Why is insertion sort preferred over other sorting algorithms (like selection sort, bubble sort etc.) for Tim sort implementation?

Because insertion sort is faster and adaptive | |

Because insertion sort requires less space | |

Because insertion sort is easy to implement | |

Because insertion sort is easy to understand |

Question 12 Explanation:

When small arrays need to be sorted then insertion sort proves to be the best choice . Also, it is adaptive so it performs better than others when the given array is fully/partially sorted.

Question 13 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

In which case will tim sort will work as an insertion sort?

when no. of elements are less than 64 | |

when no. of elements are greater than 64 | |

when no. of elements are less than size of run | |

when no. of elements are less than 32 |

Question 13 Explanation:

Tim sort uses a hybrid of insertion and merge sort. It reduces to insertion sort when the size of array is less than the size of run as insertion sort is efficient in sorting small arrays.

Question 14 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

What is the usual size of a run in tim sort?

32 | |

less than 32 | |

32-64 depending on size of the array | |

64 |

Question 14 Explanation:

Usually the size of the run is chosen somewhere between 32 and 64. The size of run is preferably chosen in powers of 2 in order to maintain balance while merging the sorted runs.

Question 15 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

What will be the output of the given Java code?

import java.util.Arrays; public class SortExample { public static void main(String[] args) { // Our arr contains 8 elements int[] arr = {10, 7, 9, 5, 8, 4}; Arrays.sort(arr); System.out.printf(Arrays.toString(arr)); } }

[4, 5, 7, 8, 9, 10] | |

[10, 9, 8, 7, 5, 4] | |

4, 5, 7, 8, 9, 10 | |

error |

Question 15 Explanation:

The given program sorts the input in ascending order by using the function Arrays.sort(). It uses Tim sort internally.

There are 15 questions to complete.