Skip to content

Commit ea68ec2

Browse files
authored
Initial File
Find minimum difference between two elements of Binary Tree | Data Structures #Python Code
1 parent 88e02ef commit ea68ec2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

min_diff.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def minimum_diff_ele(arr):
2+
arr=sorted(arr)
3+
size=len(arr)
4+
min_diff = 9999*999
5+
6+
for i in range(size-1):
7+
if(arr[i+1]- arr[i] < min_diff):
8+
min_diff = arr[i+1]- arr[i]
9+
return min_diff
10+
11+
12+
arr=[ 5, 32 , 45, 4, 12, 18, 25]
13+
print("Minimum difference between elements of an array is",minimum_diff_ele(arr))
14+
15+
16+
17+
18+

0 commit comments

Comments
 (0)