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

Commit cd0b78c

Browse files
Merge pull request #34 from sujata13/master
Updated ReadMe and Added Sorting Algorithms- Insertion Sort and Selection Sort
2 parents 6d267af + 803ed38 commit cd0b78c

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,113 @@
11
# Code-with-love
22
Open source programming algorithms
3+
4+
5+
## Instructions:
6+
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+
10+
### 1. Star and Fork this Repository
11+
###### You can star and fork this repository on GitHub by navigating at the top of this repository.
12+
13+
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:
14+
15+
https://github.com/SanjayDevTech/Code-with-love
16+
17+
18+
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.
19+
20+
### 2. Clone the Repository
21+
22+
To make your own local copy of the repository you would like to contribute to, let’s first open up a terminal window.
23+
24+
We’ll use the `git clone` command along with the URL that points to your fork of the repository.
25+
26+
This URL will be similar to the URL above, except now it will end with `.git.` The URL will look like this:
27+
https://github.com/your-username/Code-with-love.git
28+
29+
You can alternatively copy the URL by using the green “Clone or download” button from your repository page that you just forked from the original repository page. Once you click the button, you’ll be able to copy the URL by clicking the binder button next to the URL.
30+
31+
Once we have the URL, we’re ready to clone the repository. To do this, we’ll combine the git clone command with the repository URL from the command line in a terminal window:
32+
33+
`git clone https://github.com/your-username/Code-with-love.git`
34+
35+
36+
### 3. Create a New Branch
37+
38+
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.
39+
40+
##### `cd Code-with-love`
41+
42+
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.
43+
44+
##### `git branch new-branch`
45+
46+
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:
47+
48+
##### ` git checkout new-branch `
49+
50+
Once you enter the git `checkout` command, you will receive the following output:
51+
52+
###### `Output:`
53+
##### `Switched to branch 'new-branch' `
54+
55+
56+
At this point, you can now modify existing files or add new files to the project on your own branch.
57+
58+
#### Make Changes Locally
59+
60+
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:
61+
62+
##### ` git add -A ` or ` git add . `
63+
64+
Next, we’ll want to record the changes that we made to the repository with the git commit command.
65+
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+
68+
69+
If you have a very short message, you can record that with the -m flag and the message in quotes:
70+
71+
###### ` Example: `
72+
##### ` git commit -m "Updated Readme.md" `
73+
74+
###### At this point you can use the git push command to push the changes to the current branch of your forked repository:
75+
###### ` Example:`
76+
##### ` git push --set-upstream origin new-branch `
77+
78+
### 4. Update Local Repository
79+
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.*
81+
82+
We’ll first go over configuring a remote for the fork, then syncing the fork.
83+
84+
### 5. Configure a Remote for the Fork
85+
86+
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.
87+
88+
##### ` git remote add upstream https://github.com/your-username/Code-with-love.git `
89+
90+
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.
91+
92+
### 6. Sync the Fork
93+
94+
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.
95+
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:
96+
97+
##### ` git fetch upstream `
98+
99+
Switch to the local master branch of our repository:
100+
101+
##### ` git checkout master `
102+
103+
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:
104+
105+
##### ` git merge upstream/master `
106+
107+
### 7. Create Pull Request
108+
109+
At this point, you are ready to make a pull request to the original repository.
110+
111+
Navigate to your forked repository, and press the “New pull request” button on your left-hand side of your Repo page.
112+
113+
# Hurray! You have just created your First Pull Request.

python/sujata13_InsertionSort.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Python program for implementation of Insertion Sort
2+
3+
# Function to do insertion sort
4+
def insertionSort(arr):
5+
6+
# Traverse through 1 to len(arr)
7+
for i in range(1, len(arr)):
8+
9+
key = arr[i]
10+
11+
# Move elements of arr[0..i-1], that are
12+
# greater than key, to one position ahead
13+
# of their current position
14+
j = i-1
15+
while j >= 0 and key < arr[j] :
16+
arr[j + 1] = arr[j]
17+
j -= 1
18+
arr[j + 1] = key
19+
20+
21+
# Driver code to test above
22+
arr = [12, 11, 13, 5, 6]
23+
insertionSort(arr)
24+
for i in range(len(arr)):
25+
print ("% d" % arr[i])

python/sujata13_SelectionSort.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Python program for implementation of Selection
2+
# Sort
3+
import sys
4+
A = [64, 25, 12, 22, 11]
5+
6+
# Traverse through all array elements
7+
for i in range(len(A)):
8+
9+
# Find the minimum element in remaining
10+
# unsorted array
11+
min_idx = i
12+
for j in range(i+1, len(A)):
13+
if A[min_idx] > A[j]:
14+
min_idx = j
15+
16+
# Swap the found minimum element with
17+
# the first element
18+
A[i], A[min_idx] = A[min_idx], A[i]
19+
20+
# Driver code to test above
21+
print ("Sorted array")
22+
for i in range(len(A)):
23+
print("%d" %A[i]),

0 commit comments

Comments
 (0)