To the Top
File:  root - text - article - 2020 - 01 - level-order-traversal-of-binary-tree.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 194 Views, 20933 Search Bots | 73 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Microsoft:

Given the root of a binary tree, print its level-order traversal. For example:


1
/ \
2 3
/ \
4 5


The following tree should output 1, 2, 3, 4, 5.


class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right

def print_level_order(root):
# Fill this in.

root = Node(1, Node(2), Node(3, Node(4), Node(5)))
print_level_order(root)
# 1 2 3 4 5
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 194 Views, 20933 Search Bots | 73 Words Subscribe to Feed Burner

Related Articles

  1. Find the non-duplicate number
  2. Algorithm Interview: Convert Roman Numerals to Decimal
  3. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  4. Daily Interview Problem: Group Words that are Anagrams
  5. Daily Interview Problem: Look and Say Sequence
  6. Daily Interview Problem: Circle of Chained Words
  7. Daily Interview Problem: Count Number of Unival Subtrees
  8. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  9. First and Last Indices of an Element in a Sorted Array
  10. Algorithm Interview: Shifted String

Comments (0)

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />