diff --git a/README.md b/README.md deleted file mode 100644 index ba46601..0000000 --- a/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Inductions-Task0 -Repository for the Task-0 v2 of the Spider Webdev Inductions - -## Task_v2.0 - -Follow these to complete this subtask - -The basic idea of this task is to understand how collaborated projects work on github - - Fork this repo - - Clone the forked repo to your local system - - Implement a given algorithm in your favourite programming language and commit - - Push the file to the repository - - Make sure you pull the code using `git pull` before pushing your code - - After pushing the code, give a pull request or a PR to the parent repo from which you have forked from - - Your pull request will then be reviewed by the mentor diff --git a/bubble_sort.java b/bubble_sort.java new file mode 100644 index 0000000..9b73dfd --- /dev/null +++ b/bubble_sort.java @@ -0,0 +1,39 @@ + +import java.util.*; +public class Solution +{ + public static void main(String[] args) + { + int arr[] = { 10, 7, 3, 1, 9, 7, 4, 3 }; + System.out.print("Initial Array : "); + printArray(arr); + bubbleSort(arr); + } + public static void printArray(int[] arr) + { + for(int m = 0; m < arr.length; m++) + { + System.out.print(arr[m] + " "); + } + + System.out.println(); + } + static void bubbleSort(int[] arr) + { + for (int m = 0; m < arr.length; m++) + { + for (int n = 0; n < arr.length - m - 1; n++) + { + if (arr[n] > arr[n + 1]) + { + int temp = arr[n]; + arr[n] = arr[n + 1]; + arr[n + 1] = temp; + } + } + + System.out.print("After pass " + m + " : "); + printArray(arr); + } + } + }