Let NF(n, k, r) denote the maximum number of columns in an n-row matrix with entries in a finite field F in which each column has at most r nonzero entries and every k columns are linearly independent over F. We obtain near-optimal upper bounds for NF(n, k, r) in the case k > r. Namely, we show that NF(n, k, r) n r 2 + cr k where c 4 3 for large k. Our method is based on a novel reduction of the problem to the extremal problem for cycles in graphs, and yields a fast algorithm for finding short linear dependences. We present additional applications of this method to problems in extremal hypergraph theory and combinatorial number theory. "It is certainly odd to have an instruction in an algorithm asking you to play with some numbers to find a subset with product a square . . . Why should we expect to find such a subsequence, and, if it exists, how can we find it efficiently?" Carl Pomerance [32].