In COMP2521, you are allowed to use small amounts (< 10 lines) of general purpose code (not related to the assessment) obtained from external websites such as Stack Overflow. You are also allowed to use any amount of code from the current iteration of the course. If you do so, you must clearly attribute the source of this code in an accompanying comment. This comment must:

  • Be placed directly above the code that was taken
  • Briefly describe the purpose of the code
  • Contain the URL of the website from which the code was taken

Example:

// Gets a list of all prime numbers up to 'n'
List getPrimes(int n) {
    List res = ListNew();

    bool *prime = malloc((n + 1) * sizeof(bool));
    assert(prime != NULL);
    memset(prime, true, n + 1);

    // The following code was taken from https://www.geeksforgeeks.org/sieve-of-eratosthenes/
    // It uses the Sieve of Eratosthenes to generate prime numbers
    for (int p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            ListAppend(res, p);
            for (int i = p * p; i <= n; i += p) {
                prime[i] = false;
            }
        }
    }

    free(prime);
    return res;
}

Resource created Wednesday 20 December 2023, 05:34:19 PM.


Back to top

COMP2521 24T0 (Data Structures and Algorithms) is powered by WebCMS3
CRICOS Provider No. 00098G