Category : tree

I have a dictionary that contains 2 lists. {‘depth’: [0, 1, 1, 2, 3, 3, 3, 1, 1, 2, 3], ‘nodeName’: [‘root’, ‘Deleted Customers’, ‘New Customers’, ‘Region’, ‘Europe’, ‘Asia’, ‘America’, ‘Deleted Partners’, ‘New Partners’, ‘Region’, ‘Europe’]} I need to build the full path based on the lists in python. rootDeleted Customers rootNew CustomersRegionEurope rootNew CustomersRegionAsia ..

Read more

There is a standard table tennis match. The players take turns making 2 serves until the score is 10-10 or one of them reaches 11. After 10-10, overtime begins. Overtime ends as soon as one of the players gains an advantage of 2 points. Let’s say we have 2 parameters: p1 – ​​the probability of ..

Read more

I have an xgboost model which was trained outside and the output was provided in a plain text file using dump_model. The text file looks like below: booster[0]: 0:[101<0.142245024] yes=1,no=2,missing=1 1:[107<0.102833837] yes=3,no=4,missing=3 3:[101<0.039123565] yes=7,no=8,missing=7 7:leaf=-0.0142603116 8:leaf=0.023763923 4:[101<0.0646461397] yes=9,no=10,missing=9 9:leaf=-0.0345750563 10:leaf=-0.0135767004 2:[107<0.238691002] yes=5,no=6,missing=5 5:[103<0.0775454491] yes=11,no=12,missing=11 11:leaf=0.188941464 12:leaf=0.0651629418 6:[101<0.999929309] yes=13,no=14,missing=13 13:leaf=0.00403384864 14:leaf=0.236842111 booster[1]:…… booster[2]:…… … … booster[850]:…… ..

Read more

def levelorder(root): if root is None: return mylist = [] #similar to use of queue mylist.append(root) while len(mylist) > 0: print(mylist[0]) node = mylist.pop(0) #deque if node.left is not None: mylist.append(node.left) if node.right is not None: mylist.append(node.right) This is the code i’ve written in python (something similar to use of queue date structure) for level ..

Read more