测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A30046. 下列归并算法程序中,横线处应该填入的是( )def merge_sort(array): if len(array) == 1: return array _________________________ return merge(left, right)def merge(left, right): left_index, right_index, merge_array = 0, 0, l…

单选题 困难

题目描述

下列归并算法程序中,横线处应该填入的是(    )

def merge_sort(array):

      if len(array) == 1:

            return array

      _________________________

      return merge(left, right)


def merge(left, right):

      left_index, right_index, merge_array = 0, 0, list()

      while left_index < len(left) and right_index < len(right):

            if left[left_index] <= right[right_index]:

                  merge_array.append(left[left_index])

                  left_index += 1

            else:

                  merge_array.append(right[right_index])

                  right_index += 1

      merge_array = merge_array + left[left_index:] + right[right_index:]

      return merge_array

选项(单选)

上一题 下一题