Skip to content

Instantly share code, notes, and snippets.

View DagnyTagg2013's full-sized avatar

TechiMomi DagnyTagg2013

View GitHub Profile
@DagnyTagg2013
DagnyTagg2013 / Binary Tree - DelNode!
Created November 28, 2017 20:41
BinTree - DelNode
"""
DELETE node from Binary Tree
CORE CASES:
*** CAREFUL/INTERESTING
-- need to distinguish applicable SIDE(left or right child); INTO TARGET from
PARENT, as well as OUT of TARGET
- target is root => reset root to None
- target has no child; and target is LEFT or RIGHT child of parent
=> reset parent's child (specific side) to None
# 2D Matrix Ops
import sys
from functools import partial
# SLICING
"""
=> operates on SHALLOW REFERENCE PTR to COMPLEX types (like list, array);
OR actual VALUES of PRIMITIVE types (like char, int)
- https://www.python-course.eu/deep_copy.php
a[start:end] # items start through end-1 (ie NOT inclusive of END)
# calculate 1D stats on data
data = [10, 2, 38, 23, 21, 5, 38, 23]
# sum
dataSum = sum (data)
print ('sum is: {}'.format(dataSum))
# COUNT
count = len (data)
"""
PROBLEM:
4-digit number: 2284
- assume have dictionary isWord(String word)
- assume have phonenum pad digit to set of letters
- print all possible words of ANY length up to 4-digits
eg 2->A,B,C