private void permutationsUtil(String input, StringBuilder output, Map<Character, Integer> map, int pos, int depth) {    if (depth == pos) {        System.out.println(output.toString());        return;    }    for (int i = 0; i < input.length(); i++) {        Character key = input.charAt(i);        Integer value = map.get(key);        if (value == 0) {            continue;        }        output.append(key);        map.put(key, value-1);        permutationsUtil(input, output, map, pos, depth+1);        map.put(key, value);        output.deleteCharAt(output.length()-1);    }}public void permutations() {    String input = abc;    Map<Character, Integer> map = new HashMap<>(input.length());    for (char each : input.toCharArray()) {        if (map.containsKey(each)) {            map.put(each, map.get(each)+1);        } else {            map.put(each, 1);        }    }    for (int i = 1; i <= input.length(); i++) {        permutationsUtil(input, new StringBuilder(input.length()), map, i, 0);    }}The above code prints out all the permutations and sub-permutations of the string abc in an increasing order of length. For example, given the iteration where $i=2$ inside the permutations() for loop, the permutationsUtil() function will print out all the permutations corresponding to $_{2}^{3}\textrm{P}$ i.e ab, ac, etc. Ultimately, it will give the following output:abcabacbabccacbabcacbbacbcacabcbai.e. it will call the print function $\sum_{i=1}^{n} {_{i}^{n}}\textrm{P} = _{1}^{n}\textrm{P} + _{2}^{n}\textrm{P} + ... + _{n}^{n}\textrm{P}$ times. Since $_{n}^{n}\textrm{P} = n!$ is the most dominant term in the above equation and given that the print operation takes $O(n)$ time, am I correct in assuming the overall big-O complexity of the above code to be $O(n! \times n)$? All the operations inside the permutationsUtil() function other than the print operation have $O(1)$ complexity.
Big-O complexity of printing all permutations and sub-permutations of a string
algorithm analysis;time complexity;asymptotics;combinatorics;permutations