Skip to content
ES EN
Theme: automatic

Solved exercise: insertion sort vs merge sort comparisons in C

Implement insertion sort and merge sort in C, count their element comparisons under exact rules and decide which algorithm wins on each block of data.

Exam Code C · Java · Python · C++ Algorithms Exam level Tested code

Exam Code: Solved exercise: insertion sort vs merge sort comparisons in C
Algorithms and Data Structures · Midterm examQuestion 2 · 2.5 points · 30 min

A mountain weather station sends a block of temperature readings every hour, expressed in tenths of a degree. Before choosing the sorting algorithm for the hub's firmware, the team wants to know how many element comparisons each candidate makes on real blocks. Write a C program that sorts the same block with insertion sort and with merge sort, counts the comparisons of each one following exactly the rules below, and reports which one made fewer.

Input (standard input): an integer n with 0 ≤ n ≤ 5000, followed by n integers in the range of int, separated by spaces or newlines. You may assume the input is well formed.

Insertion rule. For each i from 1 to n-1, store key = v[i] and walk left with j = i-1, i-2, … while j ≥ 0. Each evaluation of v[j] > key counts as one comparison; the check j ≥ 0 does not count. If v[j] is greater, it is shifted one position to the right; as soon as it is not (equality included), the walk stops and the key is placed in v[j+1].

Merge rule. Top-down recursive merge sort on the half-open interval [lo, hi). If it holds fewer than two elements, do nothing. Otherwise mid = lo + (hi - lo) / 2 (integer division); sort [lo, mid), then [mid, hi), then merge them. While both halves have pending elements, evaluate left <= right once, which counts as one comparison; if true, the left element goes first (stable merge). When one half runs out, the rest of the other is copied without comparing.

Output: exactly four lines. The first is sorted: followed, for each value of the sorted array, by a space and the value (with n = 0 the line is just sorted:). The second is insertion: C and the third merge: M, with the comparison counts. The fourth is winner: X, where X is insertion, merge or tie depending on which made fewer comparisons.

Both algorithms must sort the original data, not the other one's result. Use a counter type that cannot overflow at the maximum size, and free all allocated memory. Print nothing else.

Sample input

6
5 2 4 6 1 3

Expected output

sorted: 1 2 3 4 5 6
insertion: 12
merge: 11
winner: merge
Correct insertion sort whose comparison count follows the exact rule (index check not counted, equal elements not shifted)
0.75
Recursive merge sort with the required split, a stable merge through an auxiliary array, and counting only while both halves still have elements
1.0
Input and output in the exact format, including n = 0 and n = 1, and correct memory management
0.5
Both algorithms start from independent copies of the original data, and the winner line is correct, including the tie
0.25

Hints

Hint 1 · Where exactly does the insertion counter go?

Split the loop condition in two: the while controls only j >= 0, and inside it you increment the counter and then evaluate v[j] > key. If you write while (j >= 0 && v[j] > key) there is no clean place to count the last comparison, the one that turns out false and stops the walk.

Hint 2 · How do I make both algorithms sort the same data?

Read the values into one array and duplicate it with memcpy before sorting anything. Insertion sort works on one array and merge sort on the other. Merge sort also needs an auxiliary array of the same size; allocate it once in main and pass it down the recursion rather than allocating it in every call.

Hint 3 · What should each recursive call return?

Make the recursive function return a long long: the comparisons of the left half, plus those of the right half, plus those of the merge. The merge function counts only inside the loop where i < mid and j < hi both hold; the two loops that copy the leftovers add nothing.

Solution

Explained solution

The point of this question is not sorting, which any first-year student can do, but counting exactly what the statement says. A counter placed one line too high or too low, or a < instead of <=, sorts just as well but yields a different number, and the number is what gets marked. That is why the program wraps each algorithm in a function that returns its count, and leaves input, copying and output to main.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Sorts v[0..n) by insertion and returns the number of v[j] > key comparisons. */
static long long insertion_sort(int *v, int n) {
    long long comps = 0;
    for (int i = 1; i < n; i++) {
        int key = v[i];
        int j = i - 1;
        while (j >= 0) {
            comps++;
            if (v[j] > key) {
                v[j + 1] = v[j];
                j--;
            } else {
                break;
            }
        }
        v[j + 1] = key;
    }
    return comps;
}

/* Merges the sorted runs v[lo..mid) and v[mid..hi) using aux. */
static long long merge_halves(int *v, int *aux, int lo, int mid, int hi) {
    long long comps = 0;
    int i = lo, j = mid, k = lo;
    while (i < mid && j < hi) {
        comps++;
        if (v[i] <= v[j]) {
            aux[k++] = v[i++];
        } else {
            aux[k++] = v[j++];
        }
    }
    while (i < mid) {
        aux[k++] = v[i++];
    }
    while (j < hi) {
        aux[k++] = v[j++];
    }
    memcpy(v + lo, aux + lo, (size_t)(hi - lo) * sizeof(int));
    return comps;
}

/* Top-down merge sort on [lo, hi); returns the number of comparisons. */
static long long merge_sort_rec(int *v, int *aux, int lo, int hi) {
    if (hi - lo < 2) {
        return 0;
    }
    int mid = lo + (hi - lo) / 2;
    long long c = merge_sort_rec(v, aux, lo, mid);
    c += merge_sort_rec(v, aux, mid, hi);
    c += merge_halves(v, aux, lo, mid, hi);
    return c;
}

int main(void) {
    int n;
    if (scanf("%d", &n) != 1 || n < 0) {
        n = 0;
    }
    size_t cap = (size_t)(n > 0 ? n : 1);
    int *orig = malloc(cap * sizeof(int));
    int *dup = malloc(cap * sizeof(int));
    int *aux = malloc(cap * sizeof(int));
    if (orig == NULL || dup == NULL || aux == NULL) {
        free(orig);
        free(dup);
        free(aux);
        return 1;
    }
    for (int i = 0; i < n; i++) {
        if (scanf("%d", &orig[i]) != 1) {
            orig[i] = 0;
        }
    }
    memcpy(dup, orig, (size_t)n * sizeof(int));

    long long ci = insertion_sort(orig, n);
    long long cm = merge_sort_rec(dup, aux, 0, n);

    printf("sorted:");
    for (int i = 0; i < n; i++) {
        printf(" %d", orig[i]);
    }
    printf("\n");
    printf("insertion: %lld\n", ci);
    printf("merge: %lld\n", cm);
    if (ci < cm) {
        printf("winner: insertion\n");
    } else if (cm < ci) {
        printf("winner: merge\n");
    } else {
        printf("winner: tie\n");
    }

    free(orig);
    free(dup);
    free(aux);
    return 0;
}

Input and copies. main reads n and allocates three arrays: orig, dup and aux. It allocates at least one element (cap) because malloc(0) may legitimately return NULL, and we do not want to mistake that for an out-of-memory failure. After reading the values, memcpy duplicates orig into dup, so insertion sort works on one and merge sort on the other, both from the same initial state. Sorting the same array twice would hand merge sort already-sorted data and report its best case.

Insertion. In insertion_sort the while checks only j >= 0; inside, comps++ comes before evaluating v[j] > key. This counts both the comparisons that cause a shift and the last one, which fails and triggers the break. When the key reaches position 0 the loop ends on the index and nothing more is counted. Because the comparison is strict, an element equal to the key stops it: that is what makes the algorithm stable and what the statement requires.

This gives a useful reading of the count: insertion comparisons = shifts + keys that stop before reaching the front. In the example there are 9 shifts and 3 stops (keys 4, 6 and 3), total 12. The shifts equal the number of inversions in the array, the idea developed in the exercise on counting inversions with merge sort in Java. In the test with duplicates there are 7 shifts and 5 stops, again 12.

Merge. merge_sort_rec returns 0 for intervals with fewer than two elements, computes mid with the statement's formula and adds up the counts of the two recursive calls and of merge_halves. In merge_halves the counter advances only inside the first loop, which requires i < mid && j < hi; the two loops that flush the leftovers do not compare. The condition v[i] <= v[j] gives the left side priority on ties. At the end, memcpy copies the run from aux back into v.

Reading the tests. In the example merge wins narrowly, 11 against 12. With the already-sorted array, insertion makes a single comparison per key (7), while every merge compares until the left half runs out, adding up to 12. With the reversed array every key travels to the front (1 + 2 + … + 7 = 28) and each merge compares until the right half runs out; since eight elements always split into equal halves, that again gives 12. The test with duplicates and negatives ends in a 12–12 tie.

That last test is the delicate one: with < instead of <= in the merge, or >= instead of > in insertion, the array would still come out sorted, but the count would change and the tie would disappear. The tests with n = 0 and n = 1 check that no loop makes a spurious comparison and that the first line is just sorted:, with no trailing space, when there is no data.

Code and tests on GitLab

The same solution in each language

C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Sorts v[0..n) by insertion and returns the number of v[j] > key comparisons. */
static long long insertion_sort(int *v, int n) {
    long long comps = 0;
    for (int i = 1; i < n; i++) {
        int key = v[i];
        int j = i - 1;
        while (j >= 0) {
            comps++;
            if (v[j] > key) {
                v[j + 1] = v[j];
                j--;
            } else {
                break;
            }
        }
        v[j + 1] = key;
    }
    return comps;
}

/* Merges the sorted runs v[lo..mid) and v[mid..hi) using aux. */
static long long merge_halves(int *v, int *aux, int lo, int mid, int hi) {
    long long comps = 0;
    int i = lo, j = mid, k = lo;
    while (i < mid && j < hi) {
        comps++;
        if (v[i] <= v[j]) {
            aux[k++] = v[i++];
        } else {
            aux[k++] = v[j++];
        }
    }
    while (i < mid) {
        aux[k++] = v[i++];
    }
    while (j < hi) {
        aux[k++] = v[j++];
    }
    memcpy(v + lo, aux + lo, (size_t)(hi - lo) * sizeof(int));
    return comps;
}

/* Top-down merge sort on [lo, hi); returns the number of comparisons. */
static long long merge_sort_rec(int *v, int *aux, int lo, int hi) {
    if (hi - lo < 2) {
        return 0;
    }
    int mid = lo + (hi - lo) / 2;
    long long c = merge_sort_rec(v, aux, lo, mid);
    c += merge_sort_rec(v, aux, mid, hi);
    c += merge_halves(v, aux, lo, mid, hi);
    return c;
}

int main(void) {
    int n;
    if (scanf("%d", &n) != 1 || n < 0) {
        n = 0;
    }
    size_t cap = (size_t)(n > 0 ? n : 1);
    int *orig = malloc(cap * sizeof(int));
    int *dup = malloc(cap * sizeof(int));
    int *aux = malloc(cap * sizeof(int));
    if (orig == NULL || dup == NULL || aux == NULL) {
        free(orig);
        free(dup);
        free(aux);
        return 1;
    }
    for (int i = 0; i < n; i++) {
        if (scanf("%d", &orig[i]) != 1) {
            orig[i] = 0;
        }
    }
    memcpy(dup, orig, (size_t)n * sizeof(int));

    long long ci = insertion_sort(orig, n);
    long long cm = merge_sort_rec(dup, aux, 0, n);

    printf("sorted:");
    for (int i = 0; i < n; i++) {
        printf(" %d", orig[i]);
    }
    printf("\n");
    printf("insertion: %lld\n", ci);
    printf("merge: %lld\n", cm);
    if (ci < cm) {
        printf("winner: insertion\n");
    } else if (cm < ci) {
        printf("winner: merge\n");
    } else {
        printf("winner: tie\n");
    }

    free(orig);
    free(dup);
    free(aux);
    return 0;
}

In C memory is your job: three malloc calls, three free calls, and beware of malloc(0), which may return NULL without it being an error. The copy is done with memcpy, and the byte count must be multiplied by sizeof(int). Counters are long long and are printed with %lld; printing a long long with %d is undefined behaviour.

Java

import java.io.IOException;

public class Main {

    static long insertionSort(int[] v) {
        long comps = 0;
        for (int i = 1; i < v.length; i++) {
            int key = v[i];
            int j = i - 1;
            while (j >= 0) {
                comps++;
                if (v[j] > key) {
                    v[j + 1] = v[j];
                    j--;
                } else {
                    break;
                }
            }
            v[j + 1] = key;
        }
        return comps;
    }

    static long mergeHalves(int[] v, int[] aux, int lo, int mid, int hi) {
        long comps = 0;
        int i = lo, j = mid, k = lo;
        while (i < mid && j < hi) {
            comps++;
            if (v[i] <= v[j]) {
                aux[k++] = v[i++];
            } else {
                aux[k++] = v[j++];
            }
        }
        while (i < mid) {
            aux[k++] = v[i++];
        }
        while (j < hi) {
            aux[k++] = v[j++];
        }
        System.arraycopy(aux, lo, v, lo, hi - lo);
        return comps;
    }

    static long mergeSort(int[] v, int[] aux, int lo, int hi) {
        if (hi - lo < 2) {
            return 0;
        }
        int mid = lo + (hi - lo) / 2;
        long c = mergeSort(v, aux, lo, mid);
        c += mergeSort(v, aux, mid, hi);
        c += mergeHalves(v, aux, lo, mid, hi);
        return c;
    }

    public static void main(String[] args) throws IOException {
        String text = new String(System.in.readAllBytes()).trim();
        String[] tok = text.isEmpty() ? new String[0] : text.split("\\s+");
        int n = tok.length > 0 ? Integer.parseInt(tok[0]) : 0;
        if (n < 0) {
            n = 0;
        }
        int[] orig = new int[n];
        for (int i = 0; i < n; i++) {
            orig[i] = Integer.parseInt(tok[i + 1]);
        }
        int[] dup = orig.clone();
        int[] aux = new int[n];

        long ci = insertionSort(orig);
        long cm = mergeSort(dup, aux, 0, n);

        StringBuilder sb = new StringBuilder("sorted:");
        for (int x : orig) {
            sb.append(' ').append(x);
        }
        sb.append('\n');
        sb.append("insertion: ").append(ci).append('\n');
        sb.append("merge: ").append(cm).append('\n');
        String winner = ci < cm ? "insertion" : (cm < ci ? "merge" : "tie");
        sb.append("winner: ").append(winner).append('\n');
        System.out.print(sb);
    }
}

In Java assigning an array to another variable does not copy it: int[] dup = orig shares the same data, and merge sort would receive the already sorted array. Use clone() or Arrays.copyOf. Counters are long, and output is collected in a StringBuilder to avoid thousands of calls to System.out.

Python

import sys


def insertion_sort(v):
    comps = 0
    for i in range(1, len(v)):
        key = v[i]
        j = i - 1
        while j >= 0:
            comps += 1
            if v[j] > key:
                v[j + 1] = v[j]
                j -= 1
            else:
                break
        v[j + 1] = key
    return comps


def merge_halves(v, aux, lo, mid, hi):
    comps = 0
    i, j, k = lo, mid, lo
    while i < mid and j < hi:
        comps += 1
        if v[i] <= v[j]:
            aux[k] = v[i]
            i += 1
        else:
            aux[k] = v[j]
            j += 1
        k += 1
    while i < mid:
        aux[k] = v[i]
        i += 1
        k += 1
    while j < hi:
        aux[k] = v[j]
        j += 1
        k += 1
    v[lo:hi] = aux[lo:hi]
    return comps


def merge_sort(v, aux, lo, hi):
    if hi - lo < 2:
        return 0
    mid = lo + (hi - lo) // 2
    c = merge_sort(v, aux, lo, mid)
    c += merge_sort(v, aux, mid, hi)
    c += merge_halves(v, aux, lo, mid, hi)
    return c


def main():
    data = sys.stdin.read().split()
    n = int(data[0]) if data else 0
    if n < 0:
        n = 0
    orig = [int(x) for x in data[1:1 + n]]
    dup = orig[:]
    aux = [0] * n

    ci = insertion_sort(orig)
    cm = merge_sort(dup, aux, 0, n)

    if ci < cm:
        winner = "insertion"
    elif cm < ci:
        winner = "merge"
    else:
        winner = "tie"
    lines = [
        "sorted:" + "".join(" " + str(x) for x in orig),
        "insertion: " + str(ci),
        "merge: " + str(cm),
        "winner: " + winner,
    ]
    sys.stdout.write("\n".join(lines) + "\n")


main()

In Python dup = orig would only create a second name for the same list; orig[:] makes a real copy. Note the integer division // when computing mid: a single / produces a float and breaks the indexing. Integers never overflow, but a worst-case insertion sort on 5000 elements runs about 12.5 million interpreted steps, which is slow compared to C.

C++

#include <iostream>
#include <string>
#include <vector>

static long long insertionSort(std::vector<int> &v) {
    long long comps = 0;
    for (int i = 1; i < (int)v.size(); i++) {
        int key = v[i];
        int j = i - 1;
        while (j >= 0) {
            comps++;
            if (v[j] > key) {
                v[j + 1] = v[j];
                j--;
            } else {
                break;
            }
        }
        v[j + 1] = key;
    }
    return comps;
}

static long long mergeHalves(std::vector<int> &v, std::vector<int> &aux, int lo, int mid, int hi) {
    long long comps = 0;
    int i = lo, j = mid, k = lo;
    while (i < mid && j < hi) {
        comps++;
        if (v[i] <= v[j]) {
            aux[k++] = v[i++];
        } else {
            aux[k++] = v[j++];
        }
    }
    while (i < mid) {
        aux[k++] = v[i++];
    }
    while (j < hi) {
        aux[k++] = v[j++];
    }
    for (int t = lo; t < hi; t++) {
        v[t] = aux[t];
    }
    return comps;
}

static long long mergeSort(std::vector<int> &v, std::vector<int> &aux, int lo, int hi) {
    if (hi - lo < 2) {
        return 0;
    }
    int mid = lo + (hi - lo) / 2;
    long long c = mergeSort(v, aux, lo, mid);
    c += mergeSort(v, aux, mid, hi);
    c += mergeHalves(v, aux, lo, mid, hi);
    return c;
}

int main() {
    int n = 0;
    if (!(std::cin >> n) || n < 0) {
        n = 0;
    }
    std::vector<int> orig(n);
    for (int i = 0; i < n; i++) {
        if (!(std::cin >> orig[i])) {
            orig[i] = 0;
        }
    }
    std::vector<int> dup = orig;
    std::vector<int> aux(n);

    long long ci = insertionSort(orig);
    long long cm = mergeSort(dup, aux, 0, n);

    std::cout << "sorted:";
    for (int x : orig) {
        std::cout << ' ' << x;
    }
    std::cout << '\n';
    std::cout << "insertion: " << ci << '\n';
    std::cout << "merge: " << cm << '\n';
    std::string winner = ci < cm ? "insertion" : (cm < ci ? "merge" : "tie");
    std::cout << "winner: " << winner << '\n';
    return 0;
}

In C++ std::vector has value semantics: dup = orig really copies the data, the opposite of Java. The trap is the reverse one: passing a vector by value to the sorting functions would sort a temporary copy and leave the original untouched, so they take std::vector&. Prefer '\n' over std::endl to avoid flushing on every line.

LanguageWhat to watch for
CIn C memory is your job: three malloc calls, three free calls, and beware of malloc(0), which may return NULL without it being an error. The copy is done with memcpy, and the byte count must be multiplied by sizeof(int). Counters are long long and are printed with %lld; printing a long long with %d is undefined behaviour.
JavaIn Java assigning an array to another variable does not copy it: int[] dup = orig shares the same data, and merge sort would receive the already sorted array. Use clone() or Arrays.copyOf. Counters are long, and output is collected in a StringBuilder to avoid thousands of calls to System.out.
PythonIn Python dup = orig would only create a second name for the same list; orig[:] makes a real copy. Note the integer division // when computing mid: a single / produces a float and breaks the indexing. Integers never overflow, but a worst-case insertion sort on 5000 elements runs about 12.5 million interpreted steps, which is slow compared to C.
C++In C++ std::vector has value semantics: dup = orig really copies the data, the opposite of Java. The trap is the reverse one: passing a vector by value to the sorting functions would sort a temporary copy and leave the original untouched, so they take std::vector&. Prefer '\n' over std::endl to avoid flushing on every line.

Test cases

CaseInputExpected outputActual outputResult
Statement example6 5 2 4 6 1 3sorted: 1 2 3 4 5 6 insertion: 12 merge: 11 winner: mergesorted: 1 2 3 4 5 6 insertion: 12 merge: 11 winner: mergeOK
Empty block0sorted: insertion: 0 merge: 0 winner: tiesorted: insertion: 0 merge: 0 winner: tieOK
Single element1 42sorted: 42 insertion: 0 merge: 0 winner: tiesorted: 42 insertion: 0 merge: 0 winner: tieOK
Already sorted8 1 2 3 4 5 6 7 8sorted: 1 2 3 4 5 6 7 8 insertion: 7 merge: 12 winner: insertionsorted: 1 2 3 4 5 6 7 8 insertion: 7 merge: 12 winner: insertionOK
Reverse order8 8 7 6 5 4 3 2 1sorted: 1 2 3 4 5 6 7 8 insertion: 28 merge: 12 winner: mergesorted: 1 2 3 4 5 6 7 8 insertion: 28 merge: 12 winner: mergeOK
Duplicates and negatives, tie7 4 -2 4 0 -2 7 4sorted: -2 -2 0 4 4 4 7 insertion: 12 merge: 12 winner: tiesorted: -2 -2 0 4 4 4 7 insertion: 12 merge: 12 winner: tieOK

Actual outputs: code compiled with gcc 14.4.0 (C17) and run in an isolated container on 6 December 2026.

Complexity

Insertion. In the worst case (decreasing order) the key at position i makes i comparisons, n(n-1)/2 in total: with n = 5000 that is 12,497,500, which still fits in a 32-bit int, but the counter is long long so we never depend on it. In the best case (already sorted) it makes exactly n-1. Time is Θ(n²) in the worst case and Θ(n) in the best; extra memory is O(1), since it sorts in place.

Merge. Merging two runs of lengths a and b takes between min(a, b) and a + b - 1 comparisons. With about log₂ n levels, each processing n elements, the total lies roughly between (n/2)·log₂ n and n·log₂ n; for n = 8, between 12 and 17. Time is Θ(n log n) in every case. Extra memory is Θ(n) for aux plus O(log n) of recursion stack. For another angle on the cost analysis of sorting, see the exercise on sorting and binary search with cost analysis in Python.

The whole program uses three arrays of n integers, so Θ(n) memory, and its running time is dominated by insertion in the worst case. With the 5000-element limit the cost is negligible in C, but do not extrapolate from the tests: insertion winning on nearly sorted data does not make it a good choice for large, shuffled blocks.

Common mistakes

  • Writing while (j >= 0 && v[j] > key) and counting inside the body: the last comparison, the false one, is lost, and the count comes out one short for every key that stops early.
  • Sorting with insertion and then passing the same, already sorted, array to merge sort: merge sort reports its best case and the winner may change.
  • Using < in the merge or >= in insertion: the array is still sorted, but the algorithm is no longer stable and the count on repeated values does not match the required one.
  • Counting comparisons in the loops that copy a half's leftovers too, or counting the index check j >= 0 as if it were an element comparison.
  • Computing mid as (lo + hi + 1) / 2 or another variant: with odd sizes the half lengths change, and so does the count.
  • Allocating the auxiliary array inside every recursive call without freeing it, or forgetting to free the three arrays at the end of main.

Variants

Count data moves as well

The examiner may ask for a fifth and sixth line with the writes into the array. In insertion_sort count every v[j + 1] = v[j] plus the final placement of the key; in merge sort, every write into aux and every element copied back into v. Merge sort always moves 2·n elements per level, even on sorted data, which shifts the balance between the algorithms when moving is more expensive than comparing.

Hybrid merge sort with a cutoff

Add a parameter k: if the run has k or fewer elements, sort it with insertion (adapting insertion_sort to work on v + lo with length hi - lo) and add its count; otherwise split as before. With k = 1 you get the original merge sort. The usual follow-up asks for the smallest k that reduces the total on nearly sorted data.

Bottom-up iterative merge sort

Instead of recursion, merge runs of width 1, 2, 4, … sweeping the array from left to right. When n is a power of two the merges are the same and the count matches; for other sizes the halves are formed differently and the number of comparisons can differ, so the statement must pin down the strategy.

On the syllabus

Sorting algorithms and their analysis sit at the core of several introductory algorithms courses. The syllabus of MIT's 6.006 Introduction to Algorithms lists sorting among the classical problems it covers, and Stanford's CS161 Design and Analysis of Algorithms describes a strong focus on algorithms for sorting and searching. Carnegie Mellon's 15-210 Parallel and Sequential Data Structures and Algorithms frames sorting as a problem to be defined precisely and analyses performance in terms of work, which is exactly the habit this question trains: fix the cost model first, then count.

Outside the US, the syllabus of the Data Structures course at UNAM's Faculty of Sciences includes arrays and recursion, the two tools this exercise relies on.

Article generated with AI.larebelion

Byline

· Chief editor · English edition · London

“If a headline needs explaining, it is not a headline.”

Comments (0)

No comments yet. You can be the first.

Write a comment