-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
记录一些经典算法 #14
Comments
数组拍平使用递归思想解
除了递归方法外,还有一个骚操作就是先利用
|
判断是否是完全二叉树所谓完全二叉树,就是深度为h的二叉树,所有叶子节点都出现在h或者h-1层,并且最后一层的叶子节点都集中在最左边。 如果进行广度优先遍历,那么在队列中,null值都会集中在队列的最末端并且中间不会有节点值,通过这个特性可以用来判断一棵树是否是完全二叉树。
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
记录日常看文章时遇到的经典算法。
洗牌算法
将一组有序的数组随机打乱。
思路: 从末位开始(也可以从首位),从还未排序的数字中随机取一个数(也可以取到自身),与当前数交换位置,依次排序直到剩最后一位。
The text was updated successfully, but these errors were encountered: