这是我的原始代码:
function a = graph_times()
merge_times = [];
for i = 100:100:1000
curr = sort_timer(i);
merge_times = [merge_times, curr(1)];
end
plot(100:100:1000, merge_times);
a = 1;
end
insertion_sort
我想修改此代码,以便merge_sort
在同一图表上绘制趋势线。下面是函数merge_sort
和insertion_sort
function c = insertion_sort(list1)
inserted = [];
for i = 1:size(list1,2)
inserted = insert_in_order(inserted,list1(1,i))
c = inserted
end
steps2=0;
function b = merge_sort(nums)
if size(nums,2) == 1
b = nums;
return;
end