User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240828)
btt0 (due 20240904)
wcp2 (due 20240904)
pct0 (bonus; due 20240905)
pct1 (bonus; due 20240905)
pct2 (due 20240905)
abc0 (due 20240906)
msi0 (due 20240911)
pct3 (bonus; due 20240911)
wcp3 (due 20240911)
msi1 (due 20240918)
pct4 (due 20240918)
wcp4 (due 20240918)
dsr0 (due 20240926)
pct5 (bonus; due 20240926)
wcp5 (due 20240926)
gfo0 (due 20241002)
pct6 (due 20241002)
pnc0 (due 20241002)
wcp6 (due 20241002)
dsr1 (due 20241009)
pct7 (bonus; due 20241009)
wcp7 (due 20241009)
bwp1 (bonus; due 20241016)
pct8 (due 20241016)
pnc1 (due 20241016)
wcp8 (due 20241016)
pct9 (bonus; due 20241023)
pnc2 (due 20241023)
wcp9 (due 20241023)
gfo1 (due 20241030)
mag0 (due 20241030)
pctA (due 20241030)
wcpA (due 20241030)
mag1 (due 20241106)
pctB (bonus; due 20241106)
wcpB (due 20241106)
mag2 (due 20241113)
pctC (due 20241113)
wcpC (due 20241113)
pctD (bonus; due 20241120)
wcpD (bonus; due 20241120)
bwp2 (bonus; due 20241204)
gfo2 (due 20241204)
pctE (bonus; due 20241204)
wcpE (bonus; due 20241204)
EoCE (due 20241216)
haas:fall2024:discrete:projects:mor0

Corning Community College

CSCS2330 Discrete Structures

PROJECT: Matrices or Recursion (MOR0)

OBJECTIVE

Explore and implement a program that implements matrices and uses matrix operations iOR implements algorithmic recursion in some central manner.

EDIT

You will want to go here to edit and fill in the various sections of the document:

MOR0

Matrix

A matrix is simply data stored within a grid. It can be thought of as a multi-dimensional array, or “an array of arrays”. For example, a 2D array may also be referred to as a matrix (a table of rows and columns). And the initialization would look something like this

int matrix[2][3] = { { 1, 7 }, { 2, 9, 6 } };

When accessing data within a matrix imagine the matrix as a coordinate grid, and the numbers you give the matrix is the coordinate point of that data within the matrix.

Like arrays, Matrices are fixed in size. You allocate the memory for it when created and it cannot be changed.

In theory, a matrix can have as many dimensions as you want. As many times as you can nest an array in an array, a matrix of that many dimensions can be created. Because that's all a matrix is, at least this type of matrix, an array of arrays to the nth degree.

Recursion

The concept of recursion is actually simple but implementing it is more challenging than you might think. Recursion works by creating a function that calls itself until it hits a base case to end/breakout of the recursion function. Along with the base case, it has another case that slowly leads to the base case.

A simple implementation of this can be seen with a function that gets the factorial value given a certain number.

Here is what that function looks like:

// Factorial function using recursion
int factorial(int n)
{
    // Base case for when the number given is 0
    if (n == 0)
    {
        return 1;
    }
 
    // Takes the given value and multiplies it by the previous factorial value
    else
    {
        // Function calls itself (calls n-1) until it reaches the base case (0)
        return n * factorial(n - 1);
    }
}

As you can see the function starts with the base case and then actually implements the logic for the function. Let's give n a value of 3. First, we are going to check if n is 0 and when it fails that check it will return 3*factorial(2), and then it will evaluate when n is 2. This pattern will continue until it evaluates n being 0. Now that the function has not been called again it returns 1 because n is 0. Now factorial(1) can complete its return, then factorial(2), and finally factorial(3). The result of factorial(3) is 6.

Properties of Recursion

Recursion can cause issues when not handled properly. The easiest way for this to happen is to cause a stack overflow.

A stack overflow occurs when a recursive function is never properly broken and repeats indefinitely until memory (the stack) is used up. This happens when the base case condition check is faulty or nonexistent.

Why Use Recursion Instead of a Loop?

There are several differences between loops and recursion. A couple of them being:

  • Loop uses repetition to go over sequential data, while recursion uses a selection structure.
  • Loops are less memory and processor intensive than recursive functions.

Recursion does have its advantages over loops though.

  • The code is easier to understand and is generally shorter.
  • Recursion can solve some problems that normal loops can not.
 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

208:mor0:final tally of results (208/208)
*:mor0:functional program demonstrating concept [104/104]
*:mor0:implements and utilizes the concept [104/104]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 1024 bytes (absolute value of data content change))
      • near the class content contribution average (a value of at least 1kiB)
      • no zero-sum commits (adding in one commit then later removing in its entirety for the sake of satisfying edit requirements)
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2024/discrete/projects/mor0.txt · Last modified: 2023/10/29 21:20 by 127.0.0.1