最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網 會員登陸 & 注冊

【Udemy高分付費課程】Python數(shù)據(jù)結構與算法 - 終極 Python 編

2022-08-16 07:51 作者:我命我掌控  | 我要投稿



more code:

https://github.com/arthur1573/DataStructures-Algorithms-Python






// O(n)

def print_items(n):
    for i in range(n):
        print(i)

print_items(10)




// drop constants

// O(n) + O(n) != O(2n) == O(n)

def print_items(n):
    for i in range(n):
        print(i)
    for j in range(n):
        print(j)

print_items(10)






// O(n^2)

def print_items(n):
    for i in range(n):
        for j in range(n):
            print(i,j)
    
print_items(10)



// O(n^2)

// O(n) * O(n) * O(n) != O(n^3) == O(n^2)

def print_items(n):
    for i in range(n):
        for j in range(n):
            for k in range(n):   
                print(i,j,k)

print_items(10)






?
02.06 Big O_ Drop Non-Dominants P9 - 00:02
?
// O(n^2) + O(n) = O(n^2 + n) = O(n^2)

def print_items(n):
    for i in range(n):
        for j in range(n):
            print(i,j)

    for k in range(n):
        print(k)

print_items(10)





// O(1)

def add_items(n):
    return n


// O(1)

def add_items(n):
    return n + n


// O(1)

def add_items(n):
    return n + n + n








// O(log n)

// log2_8 = 3




// O(a) + O(b) = O(a + b)

def print_items(a,b):
    for i in range(a):
        print(i)

    for j in range(b):
        print(j)


// O(a * b)

def print_items(a,b):
    for i in range(a):
        for j in range(b):
            print(i,j)





class Cookie:
    def __init__(self, color):
        self.color = color

cookie_one = Cookie('green')
cookie_two = Cookie('blue')




class Cookie:
    def __init__(self, color):
        self.color = color
    def get_color(self):
        return self.color
    def set_color(self, color):
        self.color = color

cookie_one = Cookie('green')
cookie_two = Cookie('blue')

print('Cookie one is', cookie_one.get_color())
print('Cookie two is', cookie_two.get_color())

cookie_one.set_color('yellow')

print('\nRight now,cookie one is', cookie_one.get_color())
print('Still, cookie two is', cookie_two.get_color())





class LinkedList:
    def __init__(self, value):

    def append(self, value):

    def pop(self):

    def prepend(self, value):

    def insert(self, index, value):

    def remove(self, index):





num1 = 11
num2 = num1

print("Before value is updated:")
print("num1 =", num1)
print("num2 =", num2)

num1 = 22
# add this ↓, result is different 
# num2 = num1

print("\nAfter value is updated:")
print("num1 =", num1)
print("num2 =", num2)





dict1 = {
    'value':11
}

dict2 = dict1

print('Before value is updated:')
print("dict1 =", dict1)
print("dict2 =", dict2)

dict1['value'] = 22
# add this ↓, result is same
# dict2 = dict1

print('\nAfter value is updated:')
print("dict1 =", dict1)
print("dict2 =", dict2)






?
04.03 LL_ Under the Hood P19 - 01:48
?
// head has a value

head: {
? ? "value": 11,
? ? "next": {
? ? ? ? "value": 3,
? ? ? ? "next": {
? ? ? ? ? ? "value": 23,
? ? ? ? ? ? "next": {
? ? ? ? ? ? ? ? "value": 7,
? ? ? ? ? ? ? ? "next": None
? ? ? ? ? ? }
? ? ? ? }
? ? }
}

print(head['next']['next']['value'])
# output: 23

print(head['value'])
# output: 11

print(head['next'])
# outlput: {'value': 3, 'next': {'value': 23, 'next': {'value': 7, 'next': None}}}




# a Node

class Node:
    def __init__(self, value):
        self.value = value
        self.next = None





# create new Node

class LinkedList:
    def __init__(self, value):
        create new Node
    def append(self, value):
        create new Node
        add Node to end
    # def pop(self):

    def prepend(self, value):
        create new Node
        add Node to beginning
    def insert(self, index, value):
        create new Node
        insert Node
    def remove(self, index):






?
04.04 LL_ Constructor P20 - 04:30
?
# head is the first node

class Node:
    def __init__(self, value):
        self.value = value
        self.next = None


class LinkedList:
    def __init__(self, value):
        new_node = Node(value)
        self.head = new_node
        self.tail = new_node
        self.length = 1

my_linked_list = LinkedList(4)

print(my_linked_list.head.value)
# output: 4





def print_list(self):
    temp = self.head
    while temp is not None:
        print(temp.value)
        temp = temp.next






# head does not have a value

head = {
    "value": None
    "next": None
}

print(head['value'])
# output: None

print(head['next'])
# output: None




【Udemy高分付費課程】Python數(shù)據(jù)結構與算法 - 終極 Python 編的評論 (共 條)

分享到微博請遵守國家法律
遂川县| 津南区| 芜湖市| 嘉禾县| 彰化县| 茌平县| 临城县| 都江堰市| 峨眉山市| 永清县| 巴林右旗| 东山县| 遂宁市| 玛多县| 安庆市| 德阳市| 叙永县| 望谟县| 金川县| 济阳县| 阿勒泰市| 枣强县| 西城区| 广水市| 汉中市| 景洪市| 商水县| 永年县| 綦江县| 新泰市| 北京市| 陆丰市| 平果县| 集安市| 绥宁县| 望都县| 昌吉市| 轮台县| 江阴市| 英超| 静海县|