• 2021-04-14 问题

    4.试将折半查找的算法改写成递归算法。Itbisearch(sqlistL,itlow,ithigh,elemtypex){If(lowhigh)retur(0else{if(L.data[mid]==x)retur(mid);elseif(L.data[mid]x)bisearch(L,low,mid-1,x);elsebisearch(L,mid+1,high,x);}}//bisearch

    4.试将折半查找的算法改写成递归算法。Itbisearch(sqlistL,itlow,ithigh,elemtypex){If(lowhigh)retur(0else{if(L.data[mid]==x)retur(mid);elseif(L.data[mid]x)bisearch(L,low,mid-1,x);elsebisearch(L,mid+1,high,x);}}//bisearch

  • 1