### Question:
TransactionTree implements Writable, Iterable<Pair<IntArrayList,Long>> { public TransactionTree() { this(DEFAULT_INITIAL_SIZE); } TransactionTree();  TransactionTree(int size);  TransactionTree(IntArrayList items, Long support);  TransactionTree(List<Pair<IntArrayList,Long>> transactionSet); void addChild(int parentNodeId, int childnodeId); void addCount(int nodeId, long nextNodeCount); int addPattern(IntArrayList myList, long addCount); int attribute(int nodeId); int childAtIndex(int nodeId, int index); int childCount(); int childCount(int nodeId); int childWithAttribute(int nodeId, int childAttribute); long count(int nodeId); Map<Integer,MutableLong> generateFList(); TransactionTree getCompressedTree(); @Override Iterator<Pair<IntArrayList,Long>> iterator(); boolean isTreeEmpty(); @Override void readFields(DataInput in); @Override void write(DataOutput out);  }### Answer:
@Test public void testTransactionTree() { TransactionTree tree = new TransactionTree(); int nodes = 0; int total = 0; for (int i = 0; i < MAX_TRANSACTIONS; i++) { IntArrayList array = generateRandomArray(); total += array.size(); nodes += tree.addPattern(array, 1 + gen.nextInt(MAX_DUPLICATION)); } log.info("Input integers: {}", total); log.info("Input data Size: {}", total * SIZE_INT / (double) MEGABYTE); log.info("Nodes in Tree: {}", nodes); log.info("Size of Tree: {}", (nodes * SIZE_INT * NUM_OF_FPTREE_FIELDS + tree.childCount() * SIZE_INT) / (double) MEGABYTE); TransactionTree vtree = new TransactionTree(); StringBuilder sb = new StringBuilder(); int count = 0; int items = 0; Iterator<Pair<IntArrayList,Long>> it = tree.iterator(); while (it.hasNext()) { Pair<IntArrayList,Long> p = it.next(); vtree.addPattern(p.getFirst(), p.getSecond()); items += p.getFirst().size(); count++; sb.append(p); } log.info("Number of transaction integers: {}", items); log.info("Size of Transactions: {}", (items * SIZE_INT + count * SIZE_LONG) / (double) MEGABYTE); log.info("Number of Transactions: {}", count); tree.getCompressedTree(); it = vtree.iterator(); StringBuilder sb1 = new StringBuilder(); while (it.hasNext()) { sb1.append(it.next()); } assertEquals(sb.toString(), sb1.toString()); TransactionTree mtree = new TransactionTree(); MultiTransactionTreeIterator mt = new MultiTransactionTreeIterator(vtree.iterator()); while (mt.hasNext()) { mtree.addPattern(mt.next(), 1); } it = mtree.iterator(); StringBuilder sb2 = new StringBuilder(); while (it.hasNext()) { sb2.append(it.next()); } assertEquals(sb.toString(), sb2.toString()); }