Skip to content
This repository was archived by the owner on Jun 26, 2022. It is now read-only.

Commit 06e8717

Browse files
Merge branch 'master' into master
2 parents 76e2ff1 + 900ed52 commit 06e8717

File tree

103 files changed

+4048
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+4048
-24
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "GreetContributor"
2+
on:
3+
pull_request_target:
4+
types: [opened,synchronize]
5+
6+
jobs:
7+
GreetCommitter:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: "Contributors!!!"
11+
uses: ibakshay/greet-contributors-action@v3
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
with:
15+
content: "Thank you for taking your time and effort for your contribution. If you are a new contributor to this repo, kindly add your username in [CONTRIBUTORS.md](https://github.com/SanjayDevTech/Code-with-love/blob/master/CONTRIBUTORS.md)"

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# C or CPP
2+
*.exe
3+
4+
# Python
5+
__pycache__/
6+
7+
# java or kotlin
8+
*.class
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
/*when you are compiling your program change the .java class file to inorder because the class declared as public*/
3+
4+
import java.io.*;
5+
import java.util.*;
6+
public class inorder{
7+
8+
private Node root;
9+
private class Node{
10+
11+
private Node left;
12+
private Node right;
13+
int data;
14+
public Node(int data){
15+
this.data=data;
16+
System.out.print(data+"\t");
17+
}
18+
}
19+
20+
public void createBinaryTree(){
21+
22+
Node first = new Node(1);
23+
Node second = new Node(2);
24+
Node third = new Node(3);
25+
Node fourth = new Node(4);
26+
Node fifth = new Node(5);
27+
28+
root = first;
29+
first.left = second;
30+
first.right = third;
31+
second.left = fourth;
32+
second.right = fifth;
33+
}
34+
35+
/* public void inorders(Node root){
36+
37+
if(root == null){
38+
return ;
39+
}
40+
inorders(root.left);
41+
System.out.print(root.data+"\t");
42+
inorders(root.right);
43+
} */
44+
45+
/* this is using the stack concept*/
46+
47+
public void inorders(){
48+
49+
if(root == null){
50+
return;
51+
}
52+
Stack<Node> stack = new Stack<>();
53+
Node temp = root;
54+
while(!stack.isEmpty() || (temp!=null)){
55+
if(temp!=null){
56+
stack.push(temp);
57+
temp = temp.left;
58+
}else{
59+
temp = stack.pop();
60+
System.out.print(temp.data+"\t");
61+
temp = temp.right;
62+
}
63+
}
64+
}
65+
66+
public static void main(String args[]){
67+
68+
inorder obj = new inorder();
69+
System.out.println("Before inorder");
70+
obj.createBinaryTree();
71+
System.out.println();
72+
System.out.println("After inorder");
73+
obj.inorders();
74+
}
75+
}

CONTRIBUTORS.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
If you have contributed to this repository, kindly add your username here
44

5-
65
- [SanjayDevtech](https://github.com/SanjayDevTech)
76
- [hritikkhurana10sm](https://github.com/hritikkhurana10sm)
87
- [finalight](https://github.com/finalight)
@@ -12,3 +11,16 @@ If you have contributed to this repository, kindly add your username here
1211
- [Mon Pacleb](https://github.com/bananaKetchup)
1312
- [lucifer79gg](https://github.com/lucifer79gg)
1413
- [sejalshri](https://github.com/sejalshri)
14+
- [afaditya](https://github.com/afaditya)
15+
- [aaishikasb](https://github.com/aaishikasb)
16+
- [sam0hack](https://github.com/sam0hack)
17+
- [shivajipotnuru](https://github.com/shivajipotnuru)
18+
- [albysabu9](https://github.com/albysabu9)
19+
- [Jayant-saksham](https://github.com/Jayant-saksham)
20+
- [Harshit564](https://github.com/Harshit564)
21+
- [sahil9001](https://github.com/sahil9001)
22+
- [southpole01](https://github.com/southpole01)
23+
- [HarshitGupta150](https://github.com/HarshitGupta150)
24+
- [qwertymaden](https://github.com/qwertymaden)
25+
- [mjnorton](https://github.com/mjnorton)
26+
- [gauravkhatri2698](https://github.com/gauravkhatri2698)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Linear Search in C
2+
3+
#include <stdio.h>
4+
5+
int search(int array[], int n, int x) {
6+
7+
// Going through array sequencially
8+
for (int i = 0; i < n; i++)
9+
if (array[i] == x)
10+
return i;
11+
return -1;
12+
}
13+
14+
int main() {
15+
int array[] = {2, 4, 0, 1, 9};
16+
int x = 1;
17+
int n = sizeof(array) / sizeof(array[0]);
18+
19+
int result = search(array, n, x);
20+
21+
(result == -1) ? printf("Element not found") : printf("Element found at index: %d", result);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Linear Search in C++
2+
3+
#include <iostream>
4+
using namespace std;
5+
6+
int search(int array[], int n, int x) {
7+
8+
// Going through array sequencially
9+
for (int i = 0; i < n; i++)
10+
if (array[i] == x)
11+
return i;
12+
return -1;
13+
}
14+
15+
int main() {
16+
int array[] = {2, 4, 0, 1, 9};
17+
int x = 1;
18+
int n = sizeof(array) / sizeof(array[0]);
19+
20+
int result = search(array, n, x);
21+
22+
(result == -1) ? cout << "Element not found" : cout << "Element found at index: " << result;
23+
}

README.md

+28-22
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
# Code-with-love
2-
Open source programming algorithms
3-
2+
<p>
3+
4+
<img src="https://1.bp.blogspot.com/-_0LKyBpwg_o/X3ZLZwpbYwI/AAAAAAAAFxc/RCMlNoMN_0cMyZ06p2aFSgyMXHLtZ4WPgCLcBGAsYHQ/s1200/Newsletter%2BFacebook%2BHeader%2B%25282%2529.jpg">
5+
</p>
46

57
## Instructions:
68

7-
*Make sure you have a GitHub account. In case you don't have one, you can create your account by visiting https://github.com/ and clicking on ``Sign up`` option at the top right corner.*
8-
9+
_Make sure you have a GitHub account. In case you don't have one, you can create your account by visiting https://github.com/ and clicking on `Sign up` option at the top right corner._
910

1011
### 1. Star and Fork this Repository
12+
1113
###### You can star and fork this repository on GitHub by navigating at the top of this repository.
1214

1315
GitHub repository URLs will reference both the username associated with the owner of the repository, as well as the repository name. For example, acmbvp is the owner of the Hacktoberfest repository, so the GitHub URL for this project is:
1416

1517
https://github.com/SanjayDevTech/Code-with-love
1618

17-
1819
When you’re on the main page of a repository, you’ll see a button to "Star" and “Fork” the repository on the upper right-hand side of the page, underneath your user icon.
1920

2021
### 2. Clone the Repository
2122

2223
To make your own local copy of the repository you would like to contribute to, let’s first open up a terminal window.
2324

24-
We’ll use the `git clone` command along with the URL that points to your fork of the repository.
25+
We’ll use the `git clone` command along with the URL that points to your fork of the repository.
2526

2627
This URL will be similar to the URL above, except now it will end with `.git.` The URL will look like this:
2728
https://github.com/your-username/Code-with-love.git
@@ -32,60 +33,65 @@ Once we have the URL, we’re ready to clone the repository. To do this, we’ll
3233

3334
`git clone https://github.com/your-username/Code-with-love.git`
3435

35-
3636
### 3. Create a New Branch
3737

3838
To create your branch, from your terminal window, change your directory so that you are working in the directory of the repository. Be sure to use the actual name of the repository (i.e. Code-with-love) to switch into that directory.
3939

40-
##### `cd Code-with-love`
40+
##### `cd Code-with-love`
4141

4242
Now, we’ll create our new branch with the git branch command. Make sure you name it descriptively so that others working on the project understand what you are working on.
4343

4444
##### `git branch new-branch`
4545

4646
Now that our new branch is created, we can switch to make sure that we are working on that branch by using the git checkout command:
4747

48-
##### ` git checkout new-branch `
48+
##### `git checkout new-branch`
4949

5050
Once you enter the git `checkout` command, you will receive the following output:
5151

52-
###### `Output:`
53-
##### `Switched to branch 'new-branch' `
52+
###### `Output:`
53+
54+
##### `Switched to branch 'new-branch' `
5455

56+
##### `code .`
57+
58+
Once you enter this command, the whole code will automatically open in your code editor
5559

5660
At this point, you can now modify existing files or add new files to the project on your own branch.
5761

5862
#### Make Changes Locally
5963

6064
Once you have modified existing files or added new files to the project, you can add them to your local repository, which you can do with the git add command. Let’s add the -A flag to add all changes that we have made:
6165

62-
##### ` git add -A ` or ` git add . `
66+
##### `git add -A` or `git add .`
6367

6468
Next, we’ll want to record the changes that we made to the repository with the git commit command.
6569

66-
*The commit message is an important aspect of your code contribution; it helps the other contributors fully understand the change you have made, why you made it, and how significant it is. Additionally, commit messages provide a historical record of the changes for the project at large, helping future contributors along the way.*
67-
70+
_The commit message is an important aspect of your code contribution; it helps the other contributors fully understand the change you have made, why you made it, and how significant it is. Additionally, commit messages provide a historical record of the changes for the project at large, helping future contributors along the way._
6871

6972
If you have a very short message, you can record that with the -m flag and the message in quotes:
7073

71-
###### ` Example: `
72-
##### ` git commit -m "Updated Readme.md" `
74+
###### `Example:`
75+
76+
##### `git commit -m "Updated Readme.md"`
7377

7478
###### At this point you can use the git push command to push the changes to the current branch of your forked repository:
79+
7580
###### ` Example:`
76-
##### ` git push --set-upstream origin new-branch `
81+
82+
##### `git push --set-upstream origin new-branch`
7783

7884
### 4. Update Local Repository
7985

80-
*While working on a project alongside other contributors, it is important for you to keep your local repository up-to-date with the project as you don’t want to make a pull request for code that will cause conflicts. To keep your local copy of the code base updated, you’ll need to sync changes.*
86+
_While working on a project alongside other contributors, it is important for you to keep your local repository up-to-date with the project as you don’t want to make a pull request for code that will cause conflicts. To keep your local copy of the code base updated, you’ll need to sync changes._
8187

8288
We’ll first go over configuring a remote for the fork, then syncing the fork.
8389

8490
### 5. Configure a Remote for the Fork
8591

8692
Next up, you’ll have to specify a new remote upstream repository for us to sync with the fork. This will be the original repository that you forked from. you’ll have to do this with the git remote add command.
8793

88-
##### ` git remote add upstream https://github.com/your-username/Code-with-love.git `
94+
##### `git remote add upstream https://github.com/your-username/Code-with-love.git`
8995

9096
In this example, // upstream // is the shortname we have supplied for the remote repository since in terms of Git, “upstream” refers to the repository that you cloned from. If you want to add a remote pointer to the repository of a collaborator, you may want to provide that collaborator’s username or a shortened nickname for the shortname.
9197

@@ -94,15 +100,15 @@ In this example, // upstream // is the shortname we have supplied for the remote
94100
Once you have configured a remote that references the upstream and original repository on GitHub, you are ready to sync your fork of the repository to keep it up-to-date.
95101
To sync your fork, from the directory of your local repository in a terminal window, you’ll have to use the // git fetch // command to fetch the branches along with their respective commits from the upstream repository. Since you used the shortname “upstream” to refer to the upstream repository, you’ll have to pass that to the command:
96102

97-
##### ` git fetch upstream `
103+
##### `git fetch upstream`
98104

99105
Switch to the local master branch of our repository:
100106

101-
##### ` git checkout master `
107+
##### `git checkout master`
102108

103109
Now merge any changes that were made in the original repository’s master branch, that you will access through your local upstream/master branch, with your local master branch:
104110

105-
##### ` git merge upstream/master `
111+
##### `git merge upstream/master`
106112

107113
### 7. Create Pull Request
108114

c/Jayant_saksham_bubble_sort.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <stdio.h>
2+
int main()
3+
{
4+
int n, A[100], swap;
5+
printf("Enter the number of elements : ");
6+
scanf("%d", &n);
7+
printf("Now enter the array elements : ");
8+
for(int i=0;i<n;i++)
9+
scanf("%d", &A[i]);
10+
for(int i=0;i<(n-1);i++){ //This line is for number of rounds (the result of first pass is the largest element get sorted)
11+
for(int j=0;j<(n-i-1);j++){ //This line is for compairing the two adjecent numbers
12+
if(A[j]>A[j+1]){
13+
swap=A[j];
14+
A[j]=A[j+1];
15+
A[j+1]=swap;
16+
}
17+
}
18+
}
19+
printf("The sort array using Bubble sort is ");
20+
for(int i=0;i<n;i++){
21+
printf("%d ", A[i]);
22+
}
23+
}
24+
25+
//the concept is ek ek karke maximum number element will get sort
26+
// f(n)=O(n2)
27+
// no's on comparisions for n element array = 1+2+3+4+5+.....(n-1)
28+
// no of swaps = 1+2+3+4+.....(n-1)
29+
// the analogy is bubble in water when stone is thrown in water
30+

c/Jayant_saksham_count_sort.c

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
int findMax(int A[], int n){
4+
int i,max;
5+
max=A[0];
6+
for(i=1;i<n;i++){
7+
if(A[i]>max){
8+
max=A[i];
9+
}
10+
}
11+
return max;
12+
}
13+
void countSort(int A[], int n){
14+
int max,i,j;
15+
int *count;
16+
max=findMax(A,n);
17+
count=(int *)malloc(sizeof(int));
18+
for(i=0;i<(max+1);i++){
19+
count[i]=0;
20+
}
21+
for(i=0;i<n;i++){
22+
count[A[i]]++;
23+
}
24+
i=0,j=0;
25+
while(i<(max+1)){
26+
if(count[i]>0){
27+
A[j]=i;
28+
j++;
29+
count[i]--;
30+
}
31+
else
32+
{
33+
i++;
34+
}
35+
}
36+
}
37+
38+
int main(){
39+
int n,i,A[10];
40+
printf("Enter n");
41+
scanf("%d",&n);
42+
printf("Enter array element");
43+
for(i=0;i<n;i++){
44+
scanf("%d",&A[i]);
45+
}
46+
int max;
47+
countSort(A,n);
48+
printf("After sorting\n");
49+
for(i=0;i<n;i++){
50+
printf("%d ",A[i]);
51+
}
52+
}
53+
54+
// it is a space consuming algorithm
55+
// in count sort we take a array with size of maximum element present in initial array
56+
// in count array, number of occurence will be stored
57+
// f(n)=O(n)

0 commit comments

Comments
 (0)