1. A method for storing information for processing packets into a ternary content addressable memory (TCAM) in a network device, wherein the TCAM is partitioned into a plurality of sections, and each section has a corresponding size that defines a corresponding maximum number of data patterns that can be stored in the section, the method comprising: determining a correspondence between values of a set of lookup bits and the plurality of sections of the TCAM so that respective values of the set of lookup bits correspond to respective sections of the TCAM, wherein the lookup bits correspond to at least one of i) information included in packets, and ii) information generated by the network device during processing of packets by the network device; for each of a plurality of data patterns associated with processing packets, assigning the data pattern to each section of the TCAM for which a fixed set of bits in the data pattern matches a corresponding value of the set of lookup bits, wherein the data patterns correspond to rules for processing packets at the network device, and at least one of i) information included in packets, and ii) information generated by the network device during processing of packets by the network device; identifying, with a processor, multiple pairs of sets of data patterns i) that have been assigned to respective pairs of sections of the TCAM and ii) that include respective one or more identical data patterns that have been assigned to multiple sections of the TCAM; determining, with the processor, two sets of data patterns, among the multiple pairs of sets of data patterns, having a highest number of identical data patterns; determining, with the processor, whether a total number of data patterns in a combined set of the determined two sets of data patterns, the combined set including only one instance of each identical data pattern, exceeds the maximum number of data patterns for the single section of the TCAM; in response to determining that the total number of data patterns in the combined set of the two sets of data patterns does not exceed the maximum number of data patterns for the single section of the TCAM, combining, with the processor, the two sets of data patterns to form the combined set so that only one instance of each identical data pattern is included in the combined set, wherein the combined set is assigned to only the single section of the TCAM, and revising, with the processor, the correspondence between values of the set of lookup bits and the plurality of sections of the TCAM so that the two different values of the set of lookup bits correspond to the only the single section of the TCAM; repeating, with the processor, the operations of determining two sets of data patterns, determining whether a total number of data patterns in a combined set of the determined two sets of data patterns exceeds the maximum number of data patterns for a single section of the TCAM, combining the two sets, and revising the correspondence, one or more times; and storing, with the processor, each data pattern to the section of the TCAM to which the data pattern is assigned.