MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A tree sort is also known as ____ sort.
A
quick
B
heap
C
shell
D
selection
Explanation: 

Detailed explanation-1: -Heapsort can be thought of as an improved selection sort: like selection sort, heapsort divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element from it and inserting it into the sorted region.

Detailed explanation-2: -Tree sort can be used as a one-time sort, but it is equivalent to quicksort as both recursively partition the elements based on a pivot, and since quicksort is in-place and has lower overhead, tree sort has few advantages over quicksort.

Detailed explanation-3: -Treesort uses the inorder traversal performed over binary search tree (BST). Building a BST of n items take O(n * depth of tree) = O(n * log n) time. Heapsort works on the logic that the largest item is stored at the root of the heap.

Detailed explanation-4: -A tree sort is a sort algorithm that builds a binary search tree from the elements to be sorted, and then traverses the tree (in-order) so that the elements come out in sorted order. Its typical use is sorting elements online: after each insertion, the set of elements seen so far is available in sorted order.

Detailed explanation-5: -Tree Sort Let’s look at the steps: Takes the elements input in an array. Creates a binary search tree by inserting data items from the array into the tree. Performs in-order traversal on the tree to get the elements in sorted order.

There is 1 question to complete.