Skip to content

Instantly share code, notes, and snippets.

View charlespunk's full-sized avatar

charlespunk charlespunk

View GitHub Profile
1. Heapsort
2. Mergesort
3. Quicksort
Given a boolean expression consisting of the symbols 0, 1, &, |, and ^, and a desired boolean result value result, implement a function to count the number of ways of parenthesizing the expression such that it evaluates to result.
Example: (1^0|0|1, true)
You have a stack of n boxes, with widths wi, height hi, and depths di. The boxes cannot be rotated and can only be stacked on top of one another if each box in the stack is strictly larger than the box above it in width, height and depth. Implemnt a method to build the tallest stack possible, where the height of a stack is the sum of the heights of each box.
Write an alogrithm to print all ways of arranging eight queens on an 8*8 chess board so that none of them share the same row, colum or diagonal. In this case, "diagonal" means all diagonals, not just the two that bisect the board.
Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways representing n cents.
Implement the "paint fill" function that one might see on many image editing programs. That is, Given a screen(represented by a two-dimensional
array of colors), a point, and a new color, fill in the surrounding area until the color changes from the original color.
Implement an algorithm to print all valid (i.e., properly opened and closed) combinations of n-pairs of parentheses.
Write a method to compute all permutations of a string.
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
public class SortHashMap {
Write a method to return all subsets of a set.