对一组无序数据,①设计直接插入排序算法;②再对得到的有序序列进行折 半查找.
答案:2 悬赏:10 手机版
解决时间 2021-02-27 01:20
- 提问者网友:沉默菋噵
- 2021-02-26 13:14
对一组无序数据,①设计直接插入排序算法;②再对得到的有序序列进行折 半查找.
最佳答案
- 五星知识达人网友:忘川信使
- 2021-02-26 14:14
Sub Insertion(MyArray(),ByVal nOrder As Integer)Dim IndexDim TEMPDim NextElementNextElement = LBound(MyArray) + 1While (NextElement LBound(MyArray) ThenIf nOrder = ASCENDING_ORDER ThenIf MyArray(Index) TEMP = MyArray(Index)MyArray(Index) = MyArray(Index - 1)MyArray(Index - 1) = TEMPIndex = Index - 1ElseExit DoEnd IfElseIf nOrder = DESCENDING_ORDER ThenIf MyArray(Index) >= MyArray(Index - 1) ThenTEMP = MyArray(Index)MyArray(Index) = MyArray(Index - 1)MyArray(Index - 1) = TEMPIndex = Index - 1ElseExit DoEnd IfEnd IfElseExit DoEnd IfgIterations = gIterations + 1LoopNextElement = NextElement + 1gIterations = gIterations + 1WendEnd SubSub 查找(ByVal ai As Integer)Dim i As IntegerDim b As Booleani = sumax / 2b = FalseDo While Not bIf ai If ai > a(i) Then i = i + (i / 2)If ai = a(i) Then b = TrueLoopIf b Then MsgBox okEnd Sub
全部回答
- 1楼网友:冷風如刀
- 2021-02-26 15:48
这个解释是对的
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯