Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions experiment-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"unit-type": "lu",
"label": "Recursion - Computer Programming",
"basedir": ".",
"LaTeXinMD": "true",
"units": [
{
"unit-type": "aim"
Expand Down Expand Up @@ -51,9 +52,9 @@
{
"target": "assignment.html",
"source": "assignment.md",
"label": "Assignment",
"label": "Assignment",
"unit-type": "task",
"content-type": "text"
"content-type": "text"
},
{
"target": "posttest.html",
Expand All @@ -71,4 +72,3 @@
}
]
}

6 changes: 3 additions & 3 deletions experiment/aim.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The aim of this experiment is to help you understand the concept of recursion in programming. Recursion is a technique where a function solves a problem by calling itself with smaller or simpler inputs, until it reaches a base case that can be solved directly. This approach allows us to break down complex problems into simpler ones, and build up the solution step by step.
The aim of this experiment is to help you understand the concept of **recursion** in programming. Recursion is a technique where a function solves a problem by calling itself with smaller or simpler inputs, until it reaches a **base case** that can be solved directly. This approach allows us to break down complex problems into simpler ones and build up the solution step by step.

For example, to compute the xth number in the Fibonacci sequence, we need to find the (x-1)th and (x-2)th numbers first. By repeatedly breaking the main problem into smaller instances of the same problem, we eventually reach cases that are easy to solve. We then use these simple solutions to construct the answer to the original problem.
For example, to compute the $x^{\text{th}}$ number in the Fibonacci sequence, we need to find the $(x-1)^{\text{th}}$ and $(x-2)^{\text{th}}$ numbers first. By repeatedly breaking the main problem into smaller instances of the same problem, we eventually reach cases that are easy to solve. We then use these simple solutions to construct the answer to the original problem.

In programming, recursion means writing a function that calls itself within its own definition. A classic example is the definition of GNU, which stands for 'GNU's Not Unix'—the name itself is part of its own definition. Another example is placing two mirrors parallel to each other, creating an infinite series of reflections. These are all forms of recursion.
In programming, recursion means writing a function that calls itself within its own definition. A classic example is the definition of **GNU**, which stands for _"GNU's Not Unix"_—the name itself is part of its own definition. Another example is placing two mirrors parallel to each other, creating an infinite series of reflections. These are all forms of recursion.

This experiment will guide you through writing and understanding recursive functions, identifying base cases, and recognizing how recursion can simplify problem-solving in computer programming.
200 changes: 71 additions & 129 deletions experiment/posttest.json

Large diffs are not rendered by default.

514 changes: 174 additions & 340 deletions experiment/pretest.json

Large diffs are not rendered by default.

65 changes: 29 additions & 36 deletions experiment/procedure.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
#### Instructions for Using the Simulation:

* **Problem Selection:**
Four problems are available, listed in the left column:
- Sum of Numbers
- Power of a Number
- Factorial of a Number
- Fibonacci Series

Select one problem from the four options.
The problem objectives and detailed statements are provided in the center column.

* **Simulation Instructions:**
After selecting a problem, review the instructions for running the simulation, located in the top bar.

* **Language Selection:**
Choose one of the three programming languages (C, Python, or JavaScript) for the code block.

* **Code Display:**
Upon language selection, the corresponding code will be displayed in the "Code Block" section.

* **Code Completion:**
Complete the code by filling in the options provided in the dropdown menus within the code. Ensure your selections align with the logic of the chosen problem.

* **Navigation and Control:**
All control buttons are located in the bottom right corner of the page.

* **Code Execution and Analysis:**
Click "Run" to execute your code and check its correctness. The following information will be displayed:
- **Variable Values:** Details of the program's variables.
- **Max-Size:** The value of 'n' selected.
- **Stack:** Visualization of stack usage for the provided values.

* **Step-Through Execution:**
Use the "<" and ">" buttons to navigate backward and forward through the program's execution.

* **Reset:**
Click "Reset" to reset the entire simulation.
- **Problem Selection:**
Four problems are available, listed in the left column:
- Sum of Numbers - Power of a Number - Factorial of a Number - Fibonacci Series
- Select one problem from the four options.
- The problem objectives and detailed statements are provided in the center column.

- **Simulation Instructions:**
After selecting a problem, review the instructions for running the simulation, located in the top bar.

- **Language Selection:**
Choose one of the three programming languages (C, Python, or JavaScript) for the code block.

- **Code Display:**
Upon language selection, the corresponding code will be displayed in the "Code Block" section.

- **Code Completion:**
Complete the code by filling in the options provided in the dropdown menus within the code. Ensure your selections align with the logic of the chosen problem.

- **Navigation and Control:**
All control buttons are located in the bottom right corner of the page.

- **Code Execution and Analysis:**
Click "Run" to execute your code and check its correctness. The following information will be displayed: - **Variable Values:** Details of the program's variables. - **Max-Size:** The value of 'n' selected. - **Stack:** Visualization of stack usage for the provided values.

- **Step-Through Execution:**
Use the "<" and ">" buttons to navigate backward and forward through the program's execution.

- **Reset:**
Click "Reset" to reset the entire simulation.
100 changes: 57 additions & 43 deletions experiment/simulation/index.html
Original file line number Diff line number Diff line change
@@ -1,55 +1,69 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Recursion | VLabs</title>
<link rel="stylesheet" type="text/css" href="./css/main.css" />
</head>
</head>

<body>
<body>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
<div class="mdl-layout__drawer">
<span class="mdl-layout-title"><a href="./index.html"
style="color:black; text-decoration:none;">Problems</a></span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="./pages/add_numbers.html">Sum of Numbers</a>
<a class="mdl-navigation__link" href="./pages/power.html">Power of a Number</a>
<a class="mdl-navigation__link" href="./pages/factorial.html">Factorial of Number</a>
<a class="mdl-navigation__link" href="./pages/fibonacci.html">Fibonacci series</a>
<!-- Add links for other problems here -->
</nav>
</div>
<main class="mdl-layout__content">
<div class="demo-separator"></div>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title"
><a href="./index.html" style="color: black; text-decoration: none"
>Problems</a
></span
>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="./pages/add_numbers.html"
>Sum of Numbers</a
>
<a class="mdl-navigation__link" href="./pages/power.html"
>Power of a Number</a
>
<a class="mdl-navigation__link" href="./pages/factorial.html"
>Factorial of Number</a
>
<a class="mdl-navigation__link" href="./pages/fibonacci.html"
>Fibonacci series</a
>
<!-- Add links for other problems here -->
</nav>
</div>
<main class="mdl-layout__content">
<div class="demo-separator"></div>

<h2 class="left-margin" style="display: inline-block;">
Recursion Experiment (Computer Programming Lab)
</h2>
<h2 class="left-margin" style="display: inline-block">
Recursion Experiment (Computer Programming Lab)
</h2>

<h4 class="left-margin">Objectives</h4>
<h4 class="left-margin">Objectives</h4>

<ul class="left-margin">
<li>To understand that some problems can be broken down into smaller similar problems.</li>
<li>To solve such problems using recursive procedures.</li>
<l1>To understand the concept of recursion.</l1>
</ul>
<ul class="left-margin">
<li>
To understand that some problems can be broken down into smaller
similar problems.
</li>
<li>To solve such problems using recursive procedures.</li>
<l1>To understand the concept of recursion.</l1>
</ul>

<h4 class="left-margin">Problem Statements</h4>
<ol class="left-margin">
<li>Find the sum of first n natural numbers using recursion.</li>
<li>Find the power of a number using recursion.</li>
<li>Find the factorial of a number using recursion.</li>
<li>Find the nth Fibonacci number using recursion.</li>
</ol>
</main>
<h4 class="left-margin">Problem Statements</h4>
<ol class="left-margin">
<li>Find the sum of first n natural numbers using recursion.</li>
<li>Find the power of a number using recursion.</li>
<li>Find the factorial of a number using recursion.</li>
<li>Find the nth Fibonacci number using recursion.</li>
</ol>
</main>
</div>

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.teal-deep_purple.min.css" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
</body>

</html>
</body>
</html>
Loading
Loading