Skip to content

Instantly share code, notes, and snippets.

View jjlumagbas's full-sized avatar

JJ Lumagbas jjlumagbas

View GitHub Profile
public class MyBinarySearchTree {
private MyTreeNode root;
private int size;
public MyBinarySearchTree() {
this.root = null;
size = 0;
}
@jjlumagbas
jjlumagbas / MyBinarySearchTree.java
Created November 11, 2016 01:11
Starter code for remove
public class MyBinarySearchTree {
private MyTreeNode root;
public MyBinarySearchTree() {
this.root = null;
}
public void add(Integer data) throws Exception {
this.root = add(root, data);
public class AVLTree {
private MyTreeNode root;
public AVLTree() {
this.root = null;
}
public void add(Integer data) throws Exception {
this.root = add(root, data);
@jjlumagbas
jjlumagbas / secret.py
Created November 17, 2016 01:27
Hide user input in Python
import getpass
age = getpass.getpass('Enter your age:')
print("Entered age is: " + age)

Guessing games

How to hide user input

import getpass
age = getpass.getpass('Enter your age:')
print("Entered age is: " + age)
@jjlumagbas
jjlumagbas / while.py
Created November 17, 2016 01:45
While-loops in Python
def foo(x, y):
current = x + y
while (current < 100):
current = current + x + y
print(current)
print("loop finished")
foo(10, 10)
@jjlumagbas
jjlumagbas / maze-specs.md
Last active November 17, 2016 04:25
Maze MP

Square

  • char
  • visited
  • location (int row, col)

Maze

  • 2d array of Squares
@jjlumagbas
jjlumagbas / variables.py
Created November 21, 2016 07:06
Local and global scope, mutable lists
greets = ["hi", "hello", "bye"]
print(greets[0].upper())
def cap_list(lst):
pass # do this
cap_list(greets)
@jjlumagbas
jjlumagbas / SplayTree.java
Last active November 22, 2016 01:25
Splay Tree
public class SplayTree {
private MyTreeNode root;
public SplayTree() {
this.root = null;
}
// convenience function for testing
public Integer root() {
@jjlumagbas
jjlumagbas / lists.py
Created November 24, 2016 03:21
Using for i to iterate through a list
def display(lst):
for el in lst:
print(el)
# display(["Hi", "Hello", "Bye"])
def display2(lst):
for i in range(0, len(lst)):