We introduce berkeDet, a dual iterative algorithm that computes the determinant of an n×n matrix via the Leibniz formula using two independent subroutines: meryemSign, which generates the complete list of permutation signs in lexicographic order, and meryemPer, which generates the corresponding permutations. Both subroutines operate by block replication and index-mapping operations, avoiding the per-step overhead inherent in classical approaches. In the standard lexicographic implementation of the Leibniz formula, computing the sign of each permutation via inversion counting costs O(n²) per permutation, and advancing to the next permutation via the naive lexicographic generator requires an O(n log n) suffix sort. Even the well-known Narayana Pandita optimization, which replaces the sort with a suffix reversal, still requires per-step scanning and swapping operations. By contrast, meryemSign generates all n! signs in Θ(n!) total time — an amortized cost of O(1) per sign — and meryemPer generates all permutations in O(n·n!) total time without any sorting, reversal, or pivot scanning at any step. The combined berkeDet algorithm therefore runs in O(n·n!) time, improving the per-permutation cost by a factor of n over the classical lexicographic approach. We prove correctness by induction and verify the algorithm computationally for matrices up to order 8. Version 2: strengthened meryemPer analysis with explicit comparison to naive (suffix sort) and optimized (Narayana Pandita) lexicographic generators.
Gülmen et al. (Thu,) studied this question.