Bisearch Summary

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在数学用语中作“邻接的”解时不用于比较等级。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值