interview
interview copied to clipboard
快排算法的疑问
https://github.com/huihut/interview/blob/e10ff5f6983130006eab46308edc05427d2542e7/Algorithm/QuickSort.h#L63
为什么 left++ 之后不交换 arr[end] 呢,移动后的 left 的位置的元素应该只是大于等于 arr[end] 而不能确定是等于吧
https://github.com/huihut/interview/blob/e10ff5f6983130006eab46308edc05427d2542e7/Algorithm/QuickSort.h#L63
为什么 left++ 之后不交换 arr[end] 呢,移动后的 left 的位置的元素应该只是大于等于 arr[end] 而不能确定是等于吧
left++根本不可能执行,因为要执行left++必须left停留在<mid的元素上,也就是说退出循环left++的循环,只能是left==right,那这时left的位置的元素已经是>mid的了
嗨,亲!谢谢你的来信,记得常联系哦!
您好,您所发送的邮件我已收到,但并不能代表着邮件已被读取或被正确理解。