-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #873 from parammittal16/add_euclidean_distance_py
Add euclidean distance program in python
- Loading branch information
Showing
2 changed files
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |