From 0fdafc4ffc26a69600253ad10f83dc8f90e514a2 Mon Sep 17 00:00:00 2001 From: parammittal16 Date: Tue, 25 Dec 2018 14:41:35 +0530 Subject: [PATCH] Add euclidean distance program in python --- .../euclidean distance/euclidean_distance.py | 6 ++++++ linkedlist.json | 18 ++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 Mathematics/euclidean distance/euclidean_distance.py diff --git a/Mathematics/euclidean distance/euclidean_distance.py b/Mathematics/euclidean distance/euclidean_distance.py new file mode 100644 index 000000000..4f08f76d2 --- /dev/null +++ b/Mathematics/euclidean distance/euclidean_distance.py @@ -0,0 +1,6 @@ +import math +# Example points in 3-dimensional space... +x = (5, 6, 7) +y = (8, 9, 9) +distance = math.sqrt(sum([(a - b) ** 2 for a, b in zip(x, y)])) +print("Euclidean distance from x to y: ",distance) \ No newline at end of file diff --git a/linkedlist.json b/linkedlist.json index c3d095563..fb5ae28bc 100644 --- a/linkedlist.json +++ b/linkedlist.json @@ -1,10 +1,8 @@ -Step 1. Create a new node and assign the address to any node say ptr. -Step 2. OVERFLOW,IF(PTR = NULL) - write : OVERFLOW and EXIT. -Step 3. ASSIGN INFO[PTR] = ITEM -Step 4. IF(START = NULL) - ASSIGN NEXT[PTR] = NULL - ELSE - ASSIGN NEXT[PTR] = START -Step 5. ASSIGN START = PTR -Step 6. EXIT +Inserting at end of linked list + +create newnode with vale newnode -> next as null +check if list is empty(head==null) +if empty, set head=newnode +if notempty then define a node pointer temp and initialize with head +keep moving temp until temp-> next is equal to null +set temp -> next=newnode