Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 4814 Name code Date/Time 21-Apr-2022 12:19:57 PM

Copy text from below

# Python program for implementation of MergeSort

def mergeSort(arr):

if len(arr) > 1:

 

# Finding the mid of the array

mid = len(arr)//2

 

# Dividing the array elements

L = arr[:mid]

 

# into 2 halves

R = arr[mid:]

 

# Sorting the first half

mergeSort(L)

 

# Sorting the second half

mergeSort(R)

 

i = j = k = 0

 

# Copy data to temp arrays L[] and R[]

while i < len(L) and j < len(R):

if L[i] < R[j]:

arr[k] = L[i]

i += 1

else:

arr[k] = R[j]

j += 1

k += 1

 

# Checking if any element was left

while i < len(L):

arr[k] = L[i]

i += 1

k += 1

 

while j < len(R):

arr[k] = R[j]

j += 1

k += 1

 

# Code to print the list

 

 

def printList(arr):

for i in range(len(arr)):

print(arr[i], end=" ")

print()

 

 

# Driver Code

if __name__ == '__main__':

arr = [12, 11, 13, 5, 6, 7]

print("Given array is", end="\n")

printList(arr)

mergeSort(arr)

print("Sorted array is: ", end="\n")

printList(arr)

 

# This code is contributed by Mayank Khanna

 





comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
4595 haris2 11-Aug-2021 09:08:24 AM
4594 haris 11-Aug-2021 09:00:09 AM
4593 abc 10-Aug-2021 10:44:40 AM
4592 Wonderland G 08-Aug-2021 08:38:12 AM
4591 weddingplann 07-Aug-2021 11:41:18 AM
4590 wedding plan 07-Aug-2021 11:39:50 AM
4589 تنظيم اعراس 07-Aug-2021 11:33:05 AM
4588 Tow Truck, 06-Aug-2021 07:22:58 PM
4587 02-Aug-2021 06:27:03 PM

[First] [Prev] 11 | 12 | 13
 
web counter
web counter


To report any error messages or bugs, or other issues, please send email at: info@pakproject.com