Skip to content

Commit

Permalink
修改
Browse files Browse the repository at this point in the history
  • Loading branch information
arkingc committed Aug 16, 2018
1 parent 84f5cc6 commit 69b8863
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
Binary file added interview/pic/math-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added interview/pic/math-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added interview/pic/math-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added interview/pic/math-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added interview/pic/math-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions interview/数学智力题.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
> 内容源自《王道程序员求职宝典》
* [一.智力题](#一智力题)
- [1.水果与标签](#1水果与标签) 🔥
- [2.假币与损失](#2假币与损失)
- [3.黑白帽子](#3黑白帽子) 🔥
- [4.重量不同的球](#4重量不同的球) 🔥
- [5.淘汰赛比赛次数](#5淘汰赛比赛次数)

<br>
<br>
<br>

# 一.智力题

## 1.水果与标签

![](pic/math-1.png)

## 2.假币与损失

![](pic/math-2.png)

## 3.黑白帽子

![](pic/math-3.png)

## 4.重量不同的球

![](pic/math-4.png)

## 5.淘汰赛比赛次数

![](pic/math-5.png)
4 changes: 2 additions & 2 deletions 数据结构与算法/算法题总结.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
+ 《剑指offer》面试题11:[旋转数组的最小数字](#旋转数组的最小数字)(`二分查找`)
+ Leetcode33:[旋转数组中查找数字](#旋转数组中查找数字)(`二分查找` `medium`)
+ Leetcode81:[旋转数组中查找数字II](#旋转数组中查找数字ii)(`二分查找` `medium`)
+ 《剑指offer》面试题53(题目一):[有序数组中查找数字的范围](#数字在排序数组中出现的次数)(`二分查找`)
+ 《剑指offer》面试题53(题目一):[有序数组中查找数字的范围](#有序数组中查找数字的范围)(`二分查找`)
+ 《剑指offer》面试题53(题目二):[缺失的数字](#缺失的数字)(`二分查找`)
+ 《剑指offer》面试题53(题目三):[数组中数值和下标相等的元素](#数组中数值和下标相等的元素)(`二分查找`)
+ Leetcode162:[查找数组中任一峰值的下标](#查找数组中任一峰值的下标)(`二分查找` `medium`)
Expand Down Expand Up @@ -1551,7 +1551,7 @@ private:

注意,问题出在新节点比a小时!此时只能更新a,如果`left_count`表示BST中比当前节点值小的节点总数,那么所有a节点右子树中的节点都应该递增其`left_count`

那么到底应该赋予`left_count`什么样的意义?现在不管a节点的左子树和右子树长什么样,并且假设a是BST中任意节点。每当一个节点需要插入a节点的左边时,比a节点小的节点都加1,这是肯定没问题的。所以我们**只能保证一种局部性质**,即**`left_count`表示该节点左子树的节点总数**
那么到底应该赋予`left_count`什么样的意义?现在不管a节点的左子树和右子树长什么样,并且假设a是BST中任意节点。每当一个节点需要插入a节点的左边时,a的左子树节点总数就加1,这是肯定没问题的。所以我们**只能保证一种局部性质,即`left_count`表示该节点左子树的节点总数**

那么如果`left_count`表示该节点左子树的节点总数,有没有办法在插入一个节点时获取整棵BST中比新节点小的节点总是?答案是肯定的,从根节点开始遍历,查找新节点的插入位置:

Expand Down

0 comments on commit 69b8863

Please sign in to comment.