hw/hw7/BinaryTrie.java
public Match longestPrefixMatch(BitSequence querySequence) {

        Node curr = bt;

        for (int i = 0; i < querySequence.length(); i += 1) {
            if (curr.isLeaf()) {
                return new Match(querySequence.firstNBits(i), curr.ch);
            } else {
                int bit = querySequence.bitAt(i);
                if (bit == 0) {
                    curr = curr.left;
                } else {
                    curr = curr.right;
                }
            }
        }

        return new Match(querySequence, curr.ch);
    }
/**
     * finds the longest prefix that matches the given
     * querySequence and returns a Match object for that Match
     */
finds the longest prefix that matches the given
querySequence and returns a Match object for that Match
finds the longest prefix that matches the given querySequence and returns a Match object for that Match
public Match longestPrefixMatch(BitSequence querySequence) {
        Node curr = bt;
        for (int i = 0; i < querySequence.length(); i += 1) {
            if (curr.isLeaf()) {
                return new Match(querySequence.firstNBits(i), curr.ch);
            } else {
                int bit = querySequence.bitAt(i);
                if (bit == 0) {
                    curr = curr.left;
                } else {
                    curr = curr.right;
                }
            }
        }
        return new Match(querySequence, curr.ch);
    }
public Match longestPrefixMatch ( BitSequence querySequence ) { Node curr = bt ; for ( int i = 0 ; i < querySequence . length ( ) ; i += 1 ) { if ( curr . isLeaf ( ) ) { return new Match ( querySequence . firstNBits ( i ) , curr . ch ) ; } else { int bit = querySequence . bitAt ( i ) ; if ( bit == 0 ) { curr = curr . left ; } else { curr = curr . right ; } } } return new Match ( querySequence , curr . ch ) ; }
finds the longest prefix that matches the given
 querySequence and returns a Match object for that Match
finds the longest prefix that matches the given querySequence and returns a Match object for that Match