Coder Social home page Coder Social logo

datastructure's People

Contributors

kokozeng avatar

Stargazers

 avatar  avatar  avatar  avatar

datastructure's Issues

总结

总结

4.11 冒泡排序、梳理华为机试和python知识点、看绝缘子机器学习处理方法
整理个人工作流在装了啥,更新repo
4.12 选择排序、插入排序、希尔排序、快速排序
4.14 归并排序,算法面试通关[优先队列] 本科毕设交流
4.15 二分查找,华为真题部分回顾

数据结构学习记录

4.9 《大话数据结构》[86/439] 数据结构与算法[19/44] 算法面试通关40讲 [0/62] 华为机试[13/108]
4.10《大话数据结构》[86/439] 数据结构与算法[19/44] 算法面试通关40讲 [6/62] 华为机试[13/108]
(warning:链表交换相邻元素的题还没做)
4.11《大话数据结构》[86/439] 数据结构与算法[21/44] 算法面试通关40讲 [9/62] 华为机试[13/108]
4.12《大话数据结构》[86/439] 数据结构与算法[30/44] 算法面试通关40讲 [9/62] 华为机试[13/108]
4.13《大话数据结构》[86/439] 数据结构与算法[30/44] 算法面试通关40讲 [9/62] 华为机试[21/108]
4.14《大话数据结构》[86/439] 数据结构与算法[33/44] 算法面试通关40讲 [12/62] 华为机试[21/108]
4.15《大话数据结构》[86/439] 数据结构与算法[36/44] 算法面试通关40讲 [12/62] 华为机试[21/108]

深度学习五百问学习记录

a, b = b, a + b

def fab(max): 
    n, a, b = 0, 0, 1 
    while n < max: 
        yield b      # 使用 yield
        #print (b) 
        a, b = b, a + b 
        n = n + 1
for n in fab(6):
    print (n, end = ' ')

1 1 2 3 5 8

a, b = b, a + b 这个操作是否是并行的?

break continue

Python continue 语句跳出本次循环,而break跳出整个循环。

continue 语句用来告诉Python跳过当前循环的剩余语句,然后继续进行下一轮循环。

continue语句用在while和for循环中.

递归的return

# 递归方式
def binary_search(alist, first, last, item):
    mid = (first + last)//2
    # 递归的退出条件
    if alist[mid] == item :
        print(mid)
        return mid
    if alist[mid] > item:
        binary_search(alist, first, mid - 1, item)
    else:
        binary_search(alist, mid + 1, last, item)

if __name__ == "__main__":
    alist=[12,34,56,45,23,523,64,123,5346,4,30]
    # 因为查找是针对有序的顺序表
    alist.sort()
    print(alist)
    pos = binary_search(alist, 0, len(alist)-1, 123)
    # 为什么输出是none return出问题了吗?
    print(pos)

[4, 12, 23, 30, 34, 45, 56, 64, 123, 523, 5346]
8
None

为什么输出是None

催更!

催更催更,这个repo好久没更新了!

关于函数return

# 快速排序
def quick_sort(alist, first, last):
    if first >= last:
        return
    min_value = alist[first]
    low = first
    high = last

    while high > low:
        while low < high and alist[high] >= min_value:
            high -= 1
        alist[low] = alist[high]
        while low < high and alist[low] < min_value:
            low +=1
        alist[high] = alist[low]
    alist[low] = min_value
    
    quick_sort(alist, first, low-1)
    quick_sort(alist, low+1, last)
    
if __name__ == "__main__":
    alist=[12,34,56,45,23,523,64,123,5346,4,30]
    quick_sort(alist, 0, len(alist)-1)
    print(alist)

[4, 12, 23, 30, 34, 45, 56, 64, 123, 523, 5346]

但是倒数第二行如果是

alist = quick_sort(alist, 0, len(alist)-1)

输出就变成None
是因为函数是对alist直接操作,没有return吗?

关于list.sort(key)

s='abc00000 12345678 90000000'
s = s.split()
print("将字符串按空格分割:", s)
s.sort()
print("字符串升序:", s)
s.sort(reverse=True)
print("字符串降序:", s)


# 获取列表的第二个元素
def takeSecond(elem):
    return elem[0]
 
# 指定第二个元素排序
'''没看懂这里是什么操作, 不是takeSecond(s)吗?还有这个key在排什么序也不懂'''
s.sort(key=takeSecond)
 
# 输出类别
print ('排序列表:', s)

将字符串按空格分割: ['abc00000', '12345678', '90000000']
字符串升序: ['12345678', '90000000', 'abc00000']
字符串降序: ['abc00000', '90000000', '12345678']
排序列表: ['12345678', '90000000', 'abc00000']

isinstance 和 type 的区别(没懂)

实例

>>>a = 111
>>> isinstance(a, int)
True
>>>

isinstance 和 type 的区别在于:

type()不会认为子类是一种父类类型。
isinstance()会认为子类是一种父类类型。

>>> class A:
...     pass
... 
>>> class B(A):
...     pass
... 
>>> isinstance(A(), A)
True
>>> type(A()) == A 
True
>>> isinstance(B(), A)
True
>>> type(B()) == A
False

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.