Data structure sorting question 2

For all weekly assignments and video thinking questions for answers and analysis,  see  Zhejiang University Data Structure Thinking Questions + Weekly Practice Answers

Topic 1: In heap sorting, element subscripts start from 0. Then for the element with subscript i, the subscripts of the left and right children are:

  • A. 2i-1, 2i

  • B. 2i, 2i + 1

  • C. 2i + 1, 2i + 2

  • D. 2i + 2, 2i + 3

Choose C

0's left child 1 right child 2, substitute in, only C pairs.

Topic 2: Heap sorting of N records. In the worst case, the time complexity is

  • A. 

  • B. 

  • C. 

  • D. 

What does this question mean? I didn't see anything to think about, shouldn't it be the NlogN introduced in the course? Choose C.

Topic three: There is a set of records (46,77,55,38,41,85), the initial heap established by heap sort is

  • A. 38,77,55,46,41,85

  • B. 38,41,46,77,55,85

  • C. 85,55,77,38,41,46

  • D. 85,77,55,38,41,46

Just build the largest heap:

Choose D

Topic 4: Heap sort is stable.

  • A. √

  • B. ×

error. A rough idea is unstable: when the minimum heap is established and when it is sorted, the order is disordered.

To be more precise, let's take an example: suppose the minimum heap created is as follows:

Published 185 original articles · praised 408 · 10,000+ views

Guess you like

Origin blog.csdn.net/tiao_god/article/details/105490827