数据结构与算法
Chromer163
机器学习 计算机视觉 信号处理
展开
-
二分法搜索python实现以及分析
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def binaray_search(list, item): low = 0 high = len(list) - 1 i = 0 while(low <= high): mid = (low + high)/2 guess = mid if guess == item: ...原创 2018-03-12 21:06:37 · 417 阅读 · 0 评论 -
leetcode刷题(python)--448. Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could yo...原创 2018-05-03 09:03:39 · 157 阅读 · 0 评论 -
leetcode刷题(python)--384. Shuffle an Array
Shuffle a set of numbers without duplicates.Example:// Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1,2,3] and return its re...原创 2018-05-07 22:52:39 · 385 阅读 · 0 评论 -
leetcode刷题(python)--338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 you sho...原创 2018-06-05 10:21:38 · 357 阅读 · 0 评论 -
二叉树的遍历--七种方式之Python实现
class Node(object): def __init__(self, data): self.elem = data self.lchild = None self.rchild = None class Tree(object): def __init__(self): self.root = None ...原创 2018-07-17 11:24:10 · 200 阅读 · 0 评论