Skip to content

Commit 8bb33c8

Browse files
authored
Merge pull request #13 from virtual-labs/testing
Testing to Main branch merging
2 parents 28d18c2 + c9f0bc0 commit 8bb33c8

File tree

13 files changed

+96
-65
lines changed

13 files changed

+96
-65
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
package.json
3+
package-lock.json
4+
build/
5+
DS_Store

experiment-descriptor.json

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,59 @@
66
{
77
"unit-type": "aim"
88
},
9+
{
10+
"target": "objective.html",
11+
"source": "objective.md",
12+
"label": "Objective",
13+
"unit-type": "task",
14+
"content-type": "text"
15+
},
916
{
1017
"target": "theory.html",
1118
"source": "theory.md",
1219
"label": "Theory",
1320
"unit-type": "task",
14-
"content-type": "video"
21+
"content-type": "text"
1522
},
1623
{
17-
"target": "theory-test.html",
18-
"source": "theorytest.json",
19-
"label": "Theory-Test",
24+
"target": "pretest.html",
25+
"source": "pretest.json",
26+
"label": "Pretest",
2027
"unit-type": "task",
2128
"content-type": "assesment"
2229
},
2330
{
24-
"target": "practice.html",
31+
"target": "procedure.html",
32+
"source": "procedure.md",
33+
"label": "Procedure",
34+
"unit-type": "task",
35+
"content-type": "text"
36+
},
37+
{
38+
"target": "simulation.html",
2539
"source": "simulation/index.html",
26-
"label": "Practice",
40+
"label": "Simulation",
41+
"unit-type": "task",
42+
"content-type": "simulation"
43+
},
44+
{
45+
"target": "towerofhanoi.html",
46+
"source": "simulation/towerofhanoi.html",
47+
"label": "Tower of Hanoi",
2748
"unit-type": "task",
2849
"content-type": "simulation"
2950
},
3051
{
3152
"target": "assignment.html",
3253
"source": "assignment.md",
33-
"label": "Assignment",
54+
"label": "Assignment",
3455
"unit-type": "task",
35-
"content-type": "text"
56+
"content-type": "text"
3657
},
3758
{
38-
"target": "practical-test.html",
39-
"source": "practicaltest.json",
40-
"label": "Practical-Test",
59+
"target": "posttest.html",
60+
"source": "posttest.json",
61+
"label": "Posttest",
4162
"unit-type": "task",
4263
"content-type": "assesment"
4364
},

experiment/Stanford_Assignment.pdf

-510 KB
Binary file not shown.

experiment/aim.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
Welcome to this experiment on _Recursion_! In this experiment, you will learn how to use recursion to solve problems by breaking them down into smaller, similar sub-problems.
1+
Sometimes solving a big problem may require us to solve smaller problems of similar nature. For example, computing the xth number in the fibonacci sequence may require us to find the x-1th and the x-2th numbers in the sequence. If we are able to break the main problem into smaller instances of the same problem again and again, so that eventually the smaller problems become trivial, then we can use the solutions to the trivial problems to progressively build bigger solutions. Consequently, we can reach the solution of our main problem. This concept when used in coding is called recursion.
22

3-
> ### More information
4-
5-
Recursion is a powerful technique that allows us to solve complex problems by dividing them into simpler ones. It works by defining a function that calls itself repeatedly until it reaches a base case that can be solved directly. By doing so, we can solve problems that would otherwise be too difficult or time-consuming to solve in one go.
6-
7-
The definition of GNU (the source of much free software) is said to be recursive because GNU stands for `GNU's Not Unix`, i.e. GNU is part of the definition of GNU! Or maybe two mirrors placed parallely! The nested images are a form of infinite recursion.
8-
9-
Here, we will explore the concept of recursion through interactive exercises. We will start with simple examples and gradually move on to more complex problems. Along the way, you will learn how to:
10-
11-
- Identify problems that can be solved using recursion
12-
- Write recursive functions that solve problems by breaking them down into smaller sub-problems
13-
- Understand the role of base cases in terminating recursive functions
14-
- Use recursion to solve real-world problems
15-
- Appreciate the beauty and power of recursion in computer science
16-
17-
By the end of this experiment, you will have gained hands-on experience in visualizing recursive code and understanding its inner workings. You will also develop problem-solving skills that will serve you well in your future.
18-
19-
So let's get started and discover the magic of recursion together!
20-
21-
> ### Pre-requisite
22-
23-
To get the most out of this experiment, you should be familiar with the basics of programming in `Python/C/JavaScript`. You should also be comfortable with using functions and loops to solve problems.
3+
For writing a recursive code for a problem, we simply call a function inside the definition of the same function. Thus the definition of GNU (the source of much free software) is said to be recursive because GNU stands for 'GNU's Not Unix', i.e. GNU is part of the definition of GNU! Or maybe two mirrors placed parallely! The nested images are a form of infinite recursion.

experiment/assignment.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
_Note_: Some of these problems can be solved using different other methods, but we would recommend you to use the method of recursion to solve these problems and get a better understanding of recursion.
44

5-
1. **Reversing a String** (Beginner)
5+
**Reversing a String** (Beginner)
66

77
Write a function `reverseString(str)` that takes in a string argument and returns the reverse of the given string.
88

99
_Input_ -> `"Calvin and Hobbes"` \
1010
_Output_ -> `"sebboH dna nivlaC"`
1111

12-
1. **Greatest Common Divisor (GCD)** (Beginner)
12+
**Greatest Common Divisor (GCD)** (Beginner)
1313

1414
Write a function `gcd(a, b)` that takes in two numbers and returns the greatest common divisor of the two numbers.
1515

@@ -19,7 +19,7 @@ _Note_: Some of these problems can be solved using different other methods, but
1919
_Input_ -> `gcd(15, 10)` \
2020
_Output_ -> `5`
2121

22-
1. **nextIsDouble** (Intermediate)
22+
**nextIsDouble** (Intermediate)
2323

2424
Write a function that takes a list, and return the number of elements in data that are followed directly by double that element.
2525

@@ -31,7 +31,7 @@ _Note_: Some of these problems can be solved using different other methods, but
3131
_Output_ -> `5` \
3232
_Explanation_ -> The elements 0, -5, 32, 64 and 9 are all followed directly by double their value.
3333

34-
1. **MaxConsecutiveSum** (Advanced)
34+
**MaxConsecutiveSum** (Advanced)
3535

3636
Write a function `maxConsecutiveSum(arr)` that takes a list of integers as input and returns the maximum sum of consecutive elements in the list. Consecutive elements are elements that appear in sequence without any gaps.
3737

@@ -43,16 +43,12 @@ _Note_: Some of these problems can be solved using different other methods, but
4343
_Output_ -> `8` \
4444
_Explanation_ -> The maximum sum of consecutive elements in the list is 8. The consecutive elements are 4, -1, -2, 1, 5.
4545

46-
1. **Binary Search** (Advanced)
46+
**Binary Search** (Advanced)
4747

4848
Write a function binarySearch(data, target) that takes in a sorted list and a target value and returns the index of the target value in the list. If the target value is not present in the list, return -1.
4949

5050
_Input_ -> `binarySearch({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 5)` \
5151
_Output_ -> `4`
5252

5353
_Input_ -> `binarySearch({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 11)` \
54-
_Output_ -> `-1`
55-
56-
1. [Stanford Recursion Assignment](./Stanford_Assignment.pdf)
57-
58-
[Reference: web.stanford.edu/class/archive/cs/cs106b/cs106b.1174/handouts/100%20Assignment%203.pdf]
54+
_Output_ -> `-1`

experiment/objective.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- To understand that some problems can be broken down into smaller similar problems.
2+
- To solve such problems using recursive procedures.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"answers": {
2424
"a": "20 40 60 80 60 40 20",
2525
"b": "80 60 40 20",
26-
"c": "20 40 60 80 80 60 40 20",
26+
"c": "20 40 80 80 40 20",
2727
"d": "20 40 60 80"
2828
},
2929
"correctAnswer": "c",

experiment/procedure.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#### Instructions for Using the Simulation:
2+
3+
* **Problem Selection:**
4+
Four problems are available, listed in the left column:
5+
- Sum of Numbers
6+
- Power of a Number
7+
- Factorial of a Number
8+
- Fibonacci Series
9+
10+
Select one problem from the four options.
11+
The problem objectives and detailed statements are provided in the center column.
12+
13+
* **Simulation Instructions:**
14+
After selecting a problem, review the instructions for running the simulation, located in the top bar.
15+
16+
* **Language Selection:**
17+
Choose one of the three programming languages (C, Python, or JavaScript) for the code block.
18+
19+
* **Code Display:**
20+
Upon language selection, the corresponding code will be displayed in the "Code Block" section.
21+
22+
* **Code Completion:**
23+
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.
24+
25+
* **Navigation and Control:**
26+
All control buttons are located in the bottom right corner of the page.
27+
28+
* **Code Execution and Analysis:**
29+
Click "Run" to execute your code and check its correctness. The following information will be displayed:
30+
- **Variable Values:** Details of the program's variables.
31+
- **Max-Size:** The value of 'n' selected.
32+
- **Stack:** Visualization of stack usage for the provided values.
33+
34+
* **Step-Through Execution:**
35+
Use the "<" and ">" buttons to navigate backward and forward through the program's execution.
36+
37+
* **Reset:**
38+
Click "Reset" to reset the entire simulation.

experiment/references.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<!-- 1. [Recursion](http://www.exforsys.com/tutorials/c-language/c-pointers.html)
2-
2. [Recursion - Pointer](http://en.wikipedia.org/wiki/Pointer_%28computer_science%29) -->
3-
1. [MCQ Questions](https://www.geeksforgeeks.org/algorithms-gq/top-mcqs-on-recursion-algorithm-with-answers/)
1+
1. [Recursion](https://en.wikipedia.org/wiki/Recursion_(computer_science))
2+
2. [Stanford Recursion Assignment](web.stanford.edu/class/archive/cs/cs106b/cs106b.1174/handouts/100%20Assignment%203.pdf)
3+
2. [MCQ Questions](https://www.geeksforgeeks.org/algorithms-gq/top-mcqs-on-recursion-algorithm-with-answers/)

0 commit comments

Comments
 (0)