Must know tree structure in coding interviews
Must know tree structure in coding interviews
Must know
tree
structures
in coding
interviews
5
8 ?
child.
2 3 children.
4 6 7
Node 6 has no
children - leaf.
5
left child is smaller right child is greater
2 9
Valid BST
1 3
5
left child is greater right child is smaller
8 4
1 3
Begin coding interview prep -> neetcode.io
Heaps
A heap is a complete binary tree satisfying the min-heap or the
max-heap property. The value of the parent node is either
strictly greater or less than its children.
i
A valid max-heap
100
left = 2 * i right = 2 * i + 1
19 36
17 3 25 1
2 7
3 2 4
5 6
These are also called a prefix tree because each node stores a
prefix of a word.
P N X
P E
nodes.
0 1 2 3 4 5
5 3 7 1 4 2
0,5
0,2 3,5
3,4 5,5
0,1 2,2
3,3 4,4
0,0 1,1
a range of indices.
Comment below
neetcode.io