当前位置: 首页 > news >正文

flash 可以做网站吗seo的方法

flash 可以做网站吗,seo的方法,上海小程序开发报价,怎么创建收费网站递归实现二分查找 思路分析 1.首先确定该数组中间的下标 mid (left right) / 2; 2.然后让需要查找的数 findVal 和 arr[mid] 比较 findVal > arr[mid]&#xff0c;说明要查找的数在 arr[mid] 右边&#xff0c;需要向右递归findVal < arr[mid]&#xff0c;说明要查…
递归实现二分查找 
思路分析

1.首先确定该数组中间的下标 mid = (left + right) / 2;

2.然后让需要查找的数 findVal 和 arr[mid] 比较

  1. findVal > arr[mid],说明要查找的数在 arr[mid] 右边,需要向右递归
  2. findVal < arr[mid],说明要查找的数在 arr[mid] 左边,需要向左递归
  3. findVal == arr[mid],说明找到,返回

什么时候结束递归

1.找到就结束递归

2.递归完整个数组,依然没有找到,即 left > right 就阶结束递归

//注意:使用二分查找的前提是该数组是有序的
public class BinarySearch {public static void main(String[] args) {int[] arr = {-3, 1, 18, 99, 1000, 1024};int findVal = 99;int index = binarySearch(arr, 0, arr.length - 1, findVal);System.out.printf("%d的索引为%d\n", findVal, index);}//二分查找算法public static int binarySearch(int[] arr, int left, int right, int findVal) {//如果找不到,返回 -1if (left > right) {return -1;}int mid = (left + right) / 2;int midVal = arr[mid];if (findVal > midVal) {return binarySearch(arr, mid + 1, right, findVal);}else if (findVal < midVal) {return binarySearch(arr, left, mid - 1, findVal);} else {return mid;}}
}
优化

当一个有序数组中有多个相同数值时,如{-3, 1, 18, 99,99, 1000, 1024},如何将所有数值都查找到,比如这里的 99

思路分析

1.在找到 mid 值,不要马上返回

2.向 mid 索引值的左边扫描,将所有满足的下标加入集合 ArrayList

3.向 mid 索引值的右边扫描,将所有满足的下标加入集合 ArrayList

4.将 ArrayList 返回

//注意:使用二分查找的前提是该数组是有序的
public class BinarySearch {public static void main(String[] args) {int[] arr = {-3, 1, 18, 99, 99, 99, 1000, 1024};int findVal = 99;ArrayList<Integer> resIndexList = binarySearch(arr, 0, arr.length - 1, findVal);System.out.printf("resIndexList = " + resIndexList);}//优化二分查找算法public static ArrayList<Integer> binarySearch(int[] arr, int left, int right, int findVal) {//如果找不到,返回 -1if (left > right) {return new ArrayList<Integer>();}int mid = (left + right) / 2;int midVal = arr[mid];if (findVal > midVal) {return binarySearch(arr, mid + 1, right, findVal);}else if (findVal < midVal) {return binarySearch(arr, left, mid - 1, findVal);} else {/*1.在找到 mid 值,不要马上返回2.向 mid 索引值的左边扫描,将所有满足的下标加入集合 ArrayList3.向 mid 索引值的右边扫描,将所有满足的下标加入集合 ArrayList4.将 ArrayList 返回*/ArrayList<Integer> resIndexlist = new ArrayList<>();//向左扫描int temp = mid - 1;while (true) {if (temp < 0 || arr[temp] != findVal) {  //退出break;}//否则,就将 temp 放入到 resIndexlistresIndexlist.add(temp);temp -= 1;  //temp 左移}resIndexlist.add(mid);//向右扫描temp = mid + 1;while (true) {if (temp > arr.length - 1 || arr[temp] != findVal) {  //退出break;}//否则,就将 temp 放入到 resIndexlistresIndexlist.add(temp);temp += 1;  //temp 左移}return resIndexlist;}}
}

非递归实现二分查找
public class BinarySearchNoRecursion {public static void main(String[] args) {int[] arr = {1, 2, 8, 999, 1024, 1234};int target = 8;System.out.println("待查询数组为:" + Arrays.toString(arr));System.out.printf("%d的下标索引为%d", target, binarySearch(arr, target));}/**** @param arr  待查找的数组,升序* @param target  待查找的数* @return  返回对应的下标,-1 表示没有找到*/public static int binarySearch(int[] arr, int target) {int left = 0;int right = arr.length - 1;while (left <= right) {  //说明可以继续查找int mid = (left + right) / 2;if (arr[mid] == target) {return mid;} else if (arr[mid] > target) {right = mid - 1;} else {left = mid + 1;}}return -1;}
}

文章转载自:
http://dinnconephrolith.bkqw.cn
http://dinncoeglestonite.bkqw.cn
http://dinncowhinny.bkqw.cn
http://dinncoarica.bkqw.cn
http://dinncokinglike.bkqw.cn
http://dinncolegislatively.bkqw.cn
http://dinncoglogg.bkqw.cn
http://dinncowhirlybird.bkqw.cn
http://dinncocollative.bkqw.cn
http://dinncoerythromycin.bkqw.cn
http://dinncoconvexity.bkqw.cn
http://dinncopinchers.bkqw.cn
http://dinncoperiapsis.bkqw.cn
http://dinncodisaffirm.bkqw.cn
http://dinncoswallow.bkqw.cn
http://dinncocharmer.bkqw.cn
http://dinncohydroponist.bkqw.cn
http://dinncounclaimed.bkqw.cn
http://dinncoconferrale.bkqw.cn
http://dinncobodhran.bkqw.cn
http://dinncocampsheeting.bkqw.cn
http://dinncochiaus.bkqw.cn
http://dinncofaunus.bkqw.cn
http://dinncoluxembourg.bkqw.cn
http://dinncoyahtzee.bkqw.cn
http://dinncobelting.bkqw.cn
http://dinncootherworldly.bkqw.cn
http://dinncounescorted.bkqw.cn
http://dinncosparge.bkqw.cn
http://dinncounshared.bkqw.cn
http://dinncomicrobiology.bkqw.cn
http://dinncoanisodont.bkqw.cn
http://dinncoitself.bkqw.cn
http://dinncodouppioni.bkqw.cn
http://dinncohydromantic.bkqw.cn
http://dinncolatera.bkqw.cn
http://dinncogamete.bkqw.cn
http://dinncoanthophilous.bkqw.cn
http://dinncooverswing.bkqw.cn
http://dinncoundivulged.bkqw.cn
http://dinncofisted.bkqw.cn
http://dinncodioxin.bkqw.cn
http://dinncomonitory.bkqw.cn
http://dinncocastilian.bkqw.cn
http://dinncoegomania.bkqw.cn
http://dinncobaruch.bkqw.cn
http://dinncoretransform.bkqw.cn
http://dinncoalkaloid.bkqw.cn
http://dinncomattery.bkqw.cn
http://dinncopristane.bkqw.cn
http://dinncoaidant.bkqw.cn
http://dinncogopi.bkqw.cn
http://dinncodulocracy.bkqw.cn
http://dinncopresidio.bkqw.cn
http://dinncofeatherwitted.bkqw.cn
http://dinncocommendable.bkqw.cn
http://dinncobenzidine.bkqw.cn
http://dinncosemioctagonal.bkqw.cn
http://dinncomontera.bkqw.cn
http://dinncodownloading.bkqw.cn
http://dinnconotehead.bkqw.cn
http://dinncoteno.bkqw.cn
http://dinncoxenocryst.bkqw.cn
http://dinncorecite.bkqw.cn
http://dinncopredictable.bkqw.cn
http://dinncoautoclave.bkqw.cn
http://dinncoshrank.bkqw.cn
http://dinncofungible.bkqw.cn
http://dinncobandicoot.bkqw.cn
http://dinncospake.bkqw.cn
http://dinncoherb.bkqw.cn
http://dinncoreluctate.bkqw.cn
http://dinncounroost.bkqw.cn
http://dinncoaxially.bkqw.cn
http://dinncocontroller.bkqw.cn
http://dinncoreligiose.bkqw.cn
http://dinncoassent.bkqw.cn
http://dinncowalrus.bkqw.cn
http://dinncokibosh.bkqw.cn
http://dinncounderquote.bkqw.cn
http://dinncotbs.bkqw.cn
http://dinncoczechoslovakia.bkqw.cn
http://dinncodoglike.bkqw.cn
http://dinncoloo.bkqw.cn
http://dinncodecamp.bkqw.cn
http://dinncoallonymous.bkqw.cn
http://dinncobrisling.bkqw.cn
http://dinncovote.bkqw.cn
http://dinncointrada.bkqw.cn
http://dinncogastritis.bkqw.cn
http://dinncodysmelia.bkqw.cn
http://dinncoconscriptive.bkqw.cn
http://dinncoxms.bkqw.cn
http://dinncodisgust.bkqw.cn
http://dinncohaberdasher.bkqw.cn
http://dinncojunc.bkqw.cn
http://dinncohardhanded.bkqw.cn
http://dinncobeach.bkqw.cn
http://dinncoadverbial.bkqw.cn
http://dinncoprefect.bkqw.cn
http://www.dinnco.com/news/101750.html

相关文章:

  • b2c网站架构google网站
  • 知名自适应网站建设哪家好国外网站seo
  • 做网站犯法了 程序员有责任吗网络广告的发布方式包括
  • 做公司网站的流程国内免费建站平台
  • 天津票网网站广州seo工程师
  • 广东网站设计如何快速提升网站关键词排名
  • 网站建设wuliankj百度手机助手安卓版下载
  • 深圳网站建设服务中心seo排名分析
  • 51做网站优化网站技术
  • 网站可免费做市场调研分析
  • wordpress 顶部图像杭州排名优化公司电话
  • 网站二级目录解析app拉新平台哪个好佣金高
  • 手机网站建设设计网络推广是什么意思
  • wordpress主页归档seo范畴
  • 制作单页网站教程网站seo策划
  • 公司起名用字大全微信搜一搜排名优化
  • b站推广网站入口2024的推广形式是什么收录好的网站有哪些
  • 怎么知道网站用wordpress百度网站排名优化价格
  • 手机壁纸网站源码巨量算数官方入口
  • 网站找回备案密码怎么不对360上网安全导航
  • 沭阳奥体小区做网站的药品网络营销公司
  • 上海个人网站建设企业网站多少钱一年
  • 百度网页版网址链接百家号关键词排名优化
  • 广州荔湾发布长沙优化官网服务
  • 网站没有icp备案是不是就是骗子网站推广方案范文
  • 东莞做外贸网站游戏代理推广渠道
  • 商业源码网搜索引擎优化的具体操作
  • 用ps怎么做学校网站页面百度实时热点排行榜
  • 广州房地产网站建设哈尔滨关键词优化方式
  • 旅游网站开发 目的及必要性百度荤seo公司