五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

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

【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 編的評論 (共 條)

分享到微博請遵守國家法律
紫云| 新兴县| 庐江县| 柘荣县| 秭归县| 普洱| 清苑县| 瓦房店市| 邹城市| 习水县| 涿鹿县| 祁阳县| 榆中县| 车致| 江都市| 晋州市| 大丰市| 长治县| 义乌市| 富裕县| 吐鲁番市| 江华| 彰化县| 乌鲁木齐县| 璧山县| 绵竹市| 宁南县| 盐边县| 电白县| 金堂县| 大悟县| 乐平市| 裕民县| 类乌齐县| 临沧市| 梁平县| 白玉县| 临沂市| 杭锦旗| 吴堡县| 信丰县|