Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
KaziRifatMorshed committed Aug 17, 2024
1 parent bfe5fd6 commit bc945a3
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 3 deletions.
3 changes: 3 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ language = "en"
multilingual = false
src = "src"
title = "Vitamin C Programming Supplement"

[output.html]
mathjax-support = true
4 changes: 4 additions & 0 deletions src/Intro_to_Algorithm/Intro_to_Algorithm.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Intro to Algorithm

## Time and space complexity - basic knowledge

It is better to have low time complexity and space complexity. But in many cases, we have to choose either one to solve our problem. Sacrificing one rather achieving both goal (goal of making minimum TC and SC) may be necessary but don’t worry that much now as a beginner. Focus on your logic building and Approach of solving problems.
23 changes: 23 additions & 0 deletions src/LinkedList/LinkedList.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# Linked List

### Prerequisites:

Structure(must), Typedef, Pointers (must), Memory, importance of data type, stack and heap region of memory, dynamic memory allocation(malloc) and how it works.

***

## Practice Problem

1. Problem: You will be given an array of integers. Use `malloc()` to allocate memory in the heap. Write a recursive solution to print them in (inputted) order. ??????????????

Input:

```
5
69 87 45 21 47
```

Output:

```
69 87 45 21 47
```
4 changes: 4 additions & 0 deletions src/PreProcessor/PreProcessor.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Pre Processor

# #define

# typedef
29 changes: 29 additions & 0 deletions src/PrimaryKnowledge/PrimaryKnowledge.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# Primary Knowledge

***

***

qwertyuiop

***

# Helpful Tools

## CPH extension

link: <https://marketplace.visualstudio.com/items?itemName=DivyanshuAgrawal.competitive-programming-helper>

![cph-img](https://github.com/agrawal-d/competitive-programming-helper/raw/HEAD/screenshots/screenshot-main.png)

#### Pros:

## Online C visual debugger <https://pythontutor.com/c.html>

#### Pros:

* visualize variables and changes step by step

#### Cons/Limitations:

* Can not take input (You have to define values of variables within source code)
* Can not process long code (Suitable for অল্প পরিমাণ কোড and beginners)
236 changes: 236 additions & 0 deletions src/Recursion/Practice_on_Recursion.md
Original file line number Diff line number Diff line change
@@ -1 +1,237 @@
# PRACTICE Recursion

Some of the sollowing problems are directly copied from [Zobayer Hasan vai's blog post on recursion](https://zobayer.blogspot.com/2009/12/cse-102-practice-recursions.html). We are grateful to his open contributions towards learning CS.\
Use the [Competitive Programming Helper (cph)](https://marketplace.visualstudio.com/items?itemName=DivyanshuAgrawal.competitive-programming-helper) extension in VS code to make your practice easier.

<i>ALL THE BEST FOR YOUR HARD WORK.</i>

### Problems on Recursion

1. You will be given an array of integers. Write a recursive solution to print it in (inputted) order.\
Input:
```
5
69 87 45 21 47
```
Output:
```
69 87 45 21 47
```

2. Same as before. Add index number (starting from 1) to each int output in increasing order (ascending order).\
Input:
```
5
69 87 45 21 47
```
Output:
```
1.69 2.87 3.45 4.21 5.47
```

3. Same as before. Add index number (starting from n) to each int and get output in reverse order.\
Input:
```
7
69 87 45 21 47 76 2
```
Output:
```
7.69 6.87 5.45 4.21 3.47 2.76 1.2
```

4. You will be given an array of integers. Write a recursive solution to print it in reverse order.
Input:
5
62 87 45 24 47
Output:
47 24 45 87 62

5. Same as before. The program will print inputted numbers except even integers.
Input:
5
62 87 45 24 47
Output:
47 45 87

6. Use recursion to find max among 2 integers.

7. Use recursion to find the max among 3 integers.

8. Use recursion to find min among 2 integers.

9. Use recursion to find min among 3 integers.

10. Write a recursive function to print an array in the following order. \[0] \[n-1] \[1] \[n-2]\[(n-1)/2] \[n/2]
Input:
5
1 5 7 8 9
Output:
1 9
5 8
7 7

11. Write a recursive program to remove all odd integers from an array. You must not use any extra array or print anything in the function. Just read the input, call the recursive function, and then print the array in main().
Input:
6
1 54 88 6 55 7
Output:
54 88 6

12. Write a recursive solution to print the polynomial series for any input n: $$ 1 + x + x^2 + ... + x^{n-1} $$
Input:
```
5
```
Output:
```
1 + x + x^2 + x^3 + x^4
```

13. Write a recursive solution to evaluate the previous polynomial for any given x and n. Like, when x=2 and n=5, we have 1 + x + x2 + ................. + xn-1 = 31
Input:
2 5
Output:
31

14. Write a recursive program to compute n!
Input:
5
Output:
120

15. Write a recursive program to compute the n-th Fibonacci number. 1st and 2nd Fibonacci numbers are 1, 1.
Input:
6
Output:
8

16. Write a recursive program to determine whether a given integer is prime or not.
Input:
49
999983
1
Output:
not prime
prime
not prime

17. Write a recursive function that finds the gcd of two non-negative integers.
Input:
25 8895
Output:
5

18. Write a recursive solution to compute the LCM of two integers. You must not use the formula lcm(a,b) = (a x b) / gcd(a,b); find lcm from scratch...
Input:
23 488
Output:
11224

19. Suppose you are given an array of integers in an arbitrary order. Write a recursive solution to find the maximum element from the array.
Input:
5
7 4 9 6 2
Output:
9

20. Write a recursive solution to find the second maximum number from a given set of integers.
Input:
5
5 8 7 9 3
Output:
8

21. Implement linear search recursively, i.e. given an array of integers, find a specific value from it. Input format: first n, the number of elements. Then n integers. Then, q, the number of queries, then q integers. Output format: for each of the q integers, print its index (within 0 to n-1) in the array or print 'not found', whichever is appropriate.
Input:
5
2 9 4 7 6
2
5 9
Output:
not found
1

22. Implement binary search recursively, i.e. given an array of sorted integers, find a query integer from it. Input format: first n, the number of elements. Then n integers. Then, q, the number of queries, then q integers. Output format: for each of the q integers, print its index (within 0 to n-1) in the array or print 'not found', whichever is appropriate.
Input:
5
1 2 3 4 5
2
3 -5
Output:
2
not found

23. Write a recursive solution to get the reverse of a given integer. The function must return an int.
Input:
123405
Output:
504321

24. Read a string from keyboard and print it in reversed order. You must not use any array to store the characters. Write a recursive solutions to solve this problem.
Input:
helloo
Output:
oolleh

25. Write a recursive program that determines whether a given sentence is palindromic or not just considering the alpha-numeric characters ('a'-'z'), ('A'-'Z'), ('0'-'9').\
\
Input:
```
madam
```
Output:
```
palindromic
```
Input:
```
hulala
```
Output:
```
not palindromic
```

26. Implement strcat(), stracpy(), strcmp() and strlen() recursively.\
\
Input:
test on your own\
Output:
test on your own

27. If you already solved the problem for finding the nth fibonacci number, then you must have a clear vision on how the program flow works. So now, in this problem, print the values of your fibonacci function in pre-order, in-order and post-order traversal. For example, when n = 5, your program calls 3 and 4 from it, from the call of 3, your program calls 1 and 2 again....... here is the picture:
Input:

```
5
```

Output:

```
Inorder: 1 3 2 5 2 4 1 3 2
Preorder: 5 3 1 2 4 2 3 1 2
Postorder: 1 2 3 2 1 2 3 4 5
```

28. All of you have seen the tower of Hanoi. You have 3 pillars 'a', 'b' and 'c', and you need transfer all disks from one pillar to another. Conditions are, only one disk at a time is movable, and you can never place a larger disk over a smaller one. Write a recursive solution to print the moves that simulates the task, a -> b means move the topmost of tower a to tower b.

Input:

```
3
```

Output:

```
a -> c
a -> b
c -> b
a -> c
b -> a
b -> c
a -> c
x
```
2 changes: 2 additions & 0 deletions src/StructureUnion/StructureUnion.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Structure & Union

# typedef struct
4 changes: 2 additions & 2 deletions src/ending/Contributions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

During our 1st year 2nd term, me along with my close 3 friends felt necessity of collaboration and assistance to start programming life for beginners. We decided to help our

After our term final examination, during Eid Vacation, my friend, [Ibnul Abrar Shahriar Seam](https://t.me/Anonymous_HF) sent me a link [https://structured-programming-ku-cse.blogspot.com/](https://structured-programming-ku-cse.blogspot.com/) and added me as a contributor.
After our term final examination, during Eid Vacation, my friend, [Ibnul Abrar Shahriar Seam](https://t.me/Anonymous_HF) sent me a link <https://structured-programming-ku-cse.blogspot.com/> and added me as a contributor. Later, my classmates [Azmain Inquaid Haque](https://www.linkedin.com/in/azmain-inquaid-haque-44a4b62b1/), and [Joydeb Gan Prokas (Durjay)](mailto:[email protected]) directly contributed to this book.

Later, [a lot happened](https://en.wikipedia.org/wiki/2024_Bangladesh_quota_reform_movement), we achieved the 2nd independence of Bangladesh on "36th July 2024" (05 August 2024) with the heroic patriotism of [Abu Sayed Vai](https://youtu.be/FdwWlU4SSjs?si=dp10wmAFPP5FXAfE), [Mir Mugdha Vai](https://youtu.be/S08aMjlgfis?si=oQB7oA6UuWj_DWrn), [and many more](https://en.prothomalo.com/bangladesh/1hmcovbabm) which motivated us to share our knowledge and thoughts to build this nation. To make it freely available for everyone and everyone's contribution, we decided to make it open by hosting in Github with mdBook.

We look forward to rebuild our motherland as well as making this world better.

---
***

...

Expand Down
4 changes: 3 additions & 1 deletion src/welcome.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Welcome

Welcome to Vitamin C Programming Supplement is a guide like book for programming beginners focusing on the C Programming Language. A lot of resources are available online. We are here to make a compilation (gather necessary one here) as well as exercises to enhance your programming skills.
$$ \text{Vitamin C Programming Supplement} $$

Welcome to Vitamin C Programming Supplement. It is a guide like book for programming beginners focusing on the C Programming Language. A lot of resources are available online. We are here to make a compilation (gather necessary one here) as well as exercises to enhance your programming skills.

We have tried to make this contest easy as possible from Bangladeshi POV and written exams. As well as we will be sharing our notes on Programming fundamentals and the C programming language.

Expand Down

0 comments on commit bc945a3

Please sign in to comment.