From 3174849813e2d5851b75aab564fc57ab566ce6fa Mon Sep 17 00:00:00 2001 From: codebasics Date: Tue, 9 Feb 2021 19:23:02 -0500 Subject: [PATCH 1/3] recursion --- algorithms/8_recursion/recursion.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 algorithms/8_recursion/recursion.py diff --git a/algorithms/8_recursion/recursion.py b/algorithms/8_recursion/recursion.py new file mode 100644 index 0000000..a903e1f --- /dev/null +++ b/algorithms/8_recursion/recursion.py @@ -0,0 +1,16 @@ +def find_sum(n): + if n==1: + return 1 + return n + find_sum(n-1) + +def fib(n): + # 0,1,1,2,3,5,8 <-- fibonacci numbers + # -------------- + # 0,1,2,3,4,5,6 <-- index + if n==0 or n==1: + return n + return fib(n-1) + fib(n-2) + +if __name__=='__main__': + print(find_sum(5)) + print(fib(10)) \ No newline at end of file From fd97ca9e7377af65b2c6e7edbbe60f287b85d047 Mon Sep 17 00:00:00 2001 From: Aravinth Date: Thu, 8 Jul 2021 19:12:09 +0530 Subject: [PATCH 2/3] range updated to get odd numbers between 1 and max number --- data_structures/2_Arrays/Solution/3_odd_even_numbers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data_structures/2_Arrays/Solution/3_odd_even_numbers.py b/data_structures/2_Arrays/Solution/3_odd_even_numbers.py index 334b53c..ec1c4b7 100644 --- a/data_structures/2_Arrays/Solution/3_odd_even_numbers.py +++ b/data_structures/2_Arrays/Solution/3_odd_even_numbers.py @@ -2,8 +2,8 @@ odd_numbers = [] -for i in range(max): - if i%2 == 1: +for i in range(1, max): + if i % 2 == 1: odd_numbers.append(i) -print("Odd numbers: ",odd_numbers) +print("Odd numbers: ", odd_numbers) From 7d353b83e3498a0c1ec58ab184045b0b94f3a68b Mon Sep 17 00:00:00 2001 From: Dhaval Patel <60363945+dhavalsays@users.noreply.github.com> Date: Sun, 13 Nov 2022 19:23:15 -0500 Subject: [PATCH 3/3] Update bubble_sort_exercise.md --- algorithms/2_BubbleSort/bubble_sort_exercise.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/2_BubbleSort/bubble_sort_exercise.md b/algorithms/2_BubbleSort/bubble_sort_exercise.md index 5068b08..e930890 100644 --- a/algorithms/2_BubbleSort/bubble_sort_exercise.md +++ b/algorithms/2_BubbleSort/bubble_sort_exercise.md @@ -36,5 +36,5 @@ elements = [ ] ``` -[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithmsAlgorithms/2_BubbleSort/bubble_sort_exercise_solution.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/2_BubbleSort/bubble_sort_exercise_solution.py)