Skip to content

Commit eab4b5b

Browse files
committed
Update README.md
1 parent a9e7c3e commit eab4b5b

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ where it is stored.**
9898
>Check each and every data in the list till the desired element
9999
or value is found.
100100
>
101-
>Example: Suppose, we want to search 33 from the given array, Searching
102-
will start from the first index and stop searching if the data is found or the list is over.
101+
>
103102
>
104103
> <p align="center">
105104
> <img src="https://user-images.githubusercontent.com/69858580/107122139-12010b80-68c0-11eb-8981-0d19b0059da3.PNG" width="500" height="100" >
@@ -145,8 +144,7 @@ will start from the first index and stop searching if the data is found or the l
145144
>+ Best case: O(1)
146145
>+ Worst Case: O(n)
147146
148-
'Algorithm':
149-
'''java
147+
Algorithm:
150148

151149
low = 1 //Start position
152150
high = n //Last position
@@ -160,13 +158,13 @@ will start from the first index and stop searching if the data is found or the l
160158
Xm < Z : low = mid + 1 // z = searching number
161159
Xm > Z : high = mid - 1
162160
Xm == Z : flag = true
163-
```javascript
161+
164162
if (flag == true){
165163
FOUND
166164
}
167165
else
168166
NOT FOUND
169-
```
167+
170168

171169
// After looking at the algorithm, you can see that there is an example in the above file(Binary_Search.java) to better understand.
172170

@@ -185,7 +183,31 @@ order.**
185183
>+ Sorting is also used to represent data in more readable formats.
186184
>
187185
>###### We will Learn:
188-
> 1. Selection Sort
189-
> 2. Insertion Sort
190-
> 3. Merge Sort
191-
> 4. Quick Sort
186+
> 1. `Selection Sort`
187+
> 2. `Insertion Sort`
188+
> 3. `Merge Sort`
189+
> 4. `Quick Sort`
190+
> <br>
191+
192+
193+
>### Selection Sort
194+
195+
196+
```javascript
197+
1. Find the smallest element in the array
198+
2. Exchange it with the element in the first position
199+
3. Find the second smallest element and exchange it with the element in the second position
200+
4. Continue until the array is sorted
201+
202+
Algorithm:
203+
204+
n ← length[A]
205+
for i ← 1 to n - 1
206+
min ← i
207+
208+
for j ← i + 1 to n
209+
if A[j] < A[min]
210+
min ← j
211+
212+
exchange A[i] ↔ A[min]
213+
```

0 commit comments

Comments
 (0)