博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bisearch Summary
阅读量:4030 次
发布时间:2019-05-24

本文共 2155 字,大约阅读时间需要 7 分钟。

1. how to calculate middle - arithmetic progression(mean)   M-S=T-M =>2M=S+T

2. while-loop or recursion: recursion will use system stack space, which should be avoided for simple problem. Recursion should be used for complex algorithm explanation.

3. when the while exit: start + 1 < end; which will exit the loop when there's only two or one elements left to divide.

4. avoid int overflow: start + (end-start)/2; python do not  have this issue.

5. how to handle duplicated values, when finding first/last position of the target

end = middle (finding first position) ; start = middle(finding last position)

 

6. how to implement it with recursion.

    when the recursive occurred: start+1 < end

   base case: start + 1 >= end

   

Properties of Recursion

All recursive solutions must satisfy three rules or properties:

1. A recursive solution must contain a base case.

2. A recursive solution must contain a recursive case.
3. A recursive solution must make progress toward the base case. 

The base case is the terminating case and represents the smallest subdivision ofthe problem. It signals the end of the virtual loop or recursive calls. 

adjacent

常用词汇
英 [ə'dʒeɪsnt]    
美 [ə'dʒeɪsnt]   
  • adj.邻近的;毗连的;接近的

Adjective:

  1. nearest in space or position; immediately adjoining without intervening space;

    "had adjacent rooms"

    "in the next room"
    "the person sitting next to me"
    "our rooms were side by side"

  2. having a common boundary or edge; abutting; touching;

    "Rhode Island has two bordering states; Massachusetts and Conncecticut"

    "the side of Germany conterminous with France"
    "Utah and the contiguous state of Idaho"
    "neighboring cities"

  3. near or close to but not necessarily touching;

    "lands adjacent to the mountains"

    "New York and adjacent cities"

用作形容词 (adj.)
  1. The house adjacent to ours has been sold.
    与我们家邻接的房子已经售出。
  2. His house is adjacent to mine.
    他的寓所与我的相毗连。
  3. The planes landed on adjacent runways.
    这些飞机在毗连的跑道上降落。
  4. The island of Cuba is adjacent to Florida.
    古巴岛接近佛罗里达。
  5. The hospital is adjacent to a church.
    这家医院紧挨着一座教堂。
adj.(形容词)
  1. adjacent的意思是“与某物邻近的,毗连的,接近的,相接触的”,可指实际的接触,也可指两者间有一空间但并未隔着其他同类的东西。
  2. adjacent在句中可用作定语或表语。
  3. adjacent多与介词to连用,意思是“与…毗邻的”。
  4. adjacent在数学用语中作“邻接的”解时不用于比较等级。

转载地址:http://tihbi.baihongyu.com/

你可能感兴趣的文章
STL::deque以及由其实现的queue和stack
查看>>
CS4344驱动
查看>>
WAV文件解析
查看>>
DAC输出音乐2-解决pu pu 声
查看>>
WPF中PATH使用AI导出SVG的方法
查看>>
WPF UI&控件免费开源库
查看>>
QT打开项目提示no valid settings file could be found
查看>>
Win10+VS+ESP32环境搭建
查看>>
Ubuntu+win10远程桌面
查看>>
flutter-实现圆角带边框的view(android无效)
查看>>
flutter-实现一个下拉刷新上拉加载的列表
查看>>
android 代码实现圆角
查看>>
flutter-解析json
查看>>
android中shader的使用
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
Android DataBinding使用2-Recycleview
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
JavaScript基础知识(2)
查看>>
转载一个webview开车指南以及实际项目中的使用
查看>>