Help. Asap
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Help. Asap

Transcribed Image Text:46 lines (36 sloC) 985 Bytes
1
2
3
4
5
6
7
8
9
#Given a binary tree, find the deepest node
# that is the left child of its parent node.
# Example:
# 1
# /
# 2
# / \
# 4 5
3
10
11
12
# 7
13 # should return 4.
14
15
16
17
18
19
20
21
22
23
24 def find_deepest_left(root, is_left, depth, res):
25
if not root:
26
27
28
29
30
31
32
33
34 if __name__ == '_____main__':
35
root = TreeNode (1)
36
root.left = TreeNode (2)
37
root.right = TreeNode (3)
38
39
40
41
42
43
44
45
46
6
from tree.tree import TreeNode
class Deepest Left:
def __init__(self):
self.depth = 0
self. Node = None
return
if is left and depth>res.depth:
res.depth =
res. Node = root
find_deepest_left(root.left, True, depth + 1, res)
find_deepest_left(root.right, False, depth + 1, res)
depth
root.left.left = TreeNode (4)
root.left.right = TreeNode (5)
root.right.right = TreeNode (6)
root.right.right.right = TreeNode (7)
res= Deepest Left()
find_deepest_left(root, True, 1, res)
if res.Node:
print (res.Node.val)
Raw Blame
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education