Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tri fusion python code

def m(left, right):
    if not len(left) or not len(right):
        return left or right
 
    result = []
    i, j = 0, 0
    while (len(result) < len(left) + len(right)):
        if left[i] < right[j]:
            result.append(left[i])
            i+= 1
        else:
            result.append(right[j])
            j+= 1
        if i == len(left) or j == len(right):
            result.extend(left[i:] or right[j:])
            break
 
    return result
 
def msort(list):
    if len(list) < 2:
        return list
 
    middle = int(len(list)/2)
    left = msort(list[:middle])
    right = msort(list[middle:])
 
    return m(left, right)
     
lst = [5, 9, 3, 7, 15, 6]
print("Given List:")
print(lst);
print("
")
print("Sorted List:")
print(msort(lst))
Comment

PREVIOUS NEXT
Code Example
Python :: convert file dta in csv 
Python :: get all ForeignKey data by nesting in django 
Python :: df shape 
Python :: tkinter window minsize 
Python :: django admin text box 
Python :: change edit last line python 
Python :: odoo docker addons path 
Python :: python sum only numbers 
Python :: extract specific key values from nested dictionary 
Python :: python walrus operator 
Python :: matplotlib yaxis off 
Python :: google scikit learn decision tree 
Python :: re.search 
Python :: input check in pygame 
Python :: keras backend matrix multiplication 
Python :: python write data to file with permissions 
Python :: python get dir from path 
Python :: binary search tree python 
Python :: how to loop function until true python 
Python :: us states and capitals dictionary 
Python :: binary tree python 
Python :: python 2 print sep end 
Python :: warnings.warn("DateTimeField %s received a naive datetime (%s)" 
Python :: relu python 
Python :: python unittest multiple test cases 
Python :: image deblurring python 
Python :: sum range 
Python :: how to average only positive number in array numpy 
Python :: matplotlib tick label position left and right x axis 
Python :: Django - Knox auth setup 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =