Severity: Warning
Message: fopen(/tmp/ci_sessionkd4m3o00f8c0spifo714b8anb5u7s8sr): failed to open stream: No space left on device
Filename: drivers/Session_files_driver.php
Line Number: 176
Backtrace:
File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct
File: /var/www/html/index.php
Line: 311
Function: require_once
Severity: Warning
Message: session_start(): Failed to read session data: user (path: /tmp)
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct
File: /var/www/html/index.php
Line: 311
Function: require_once
By PRIYA KUMARI
Python program to find Lowest Common Ancestor (LCA) of n1 and n2 using one traversal of Binary tree
Lowest Common Ancestor in Python for a binary tree
Implementation Involves:- We find LCA of binary tree using recursive approach. We created a function returns pointer to LCA of two given values n1 and n2, it assumes that n1 and n2 are present in Binary Tree. If either n1 or n2 matches with root's key, it will tell presence by returning root. Then it will Look for keys in left and right subtrees, and according to the function it will tell whether the one key is present in once subtree and other is present in other or check if left subtree or right subtree is LCA.
Requirements:
1. Python 3.x
2. A text editor
How to Run:
1. Create a project in your text editor named binary_LCA and implement this python code in binary_LCA.py.
2. Run the file by writing the command on terminal "python filename.py".
Code
Output

Submitted by PRIYA KUMARI (priyaCode25)
Download packets of source code on Coders Packet
Comments