This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To run this code Just right click then Run file or shif 6 | |
import java.util.Arrays; | |
public class MergeSort { | |
public void Sort(int[] arr) { | |
if (arr.length < 2) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<windows.h> | |
#include<conio.h> | |
#include<fstream> | |
#include<cstring> | |
#include<cstdio> | |
#include<cstdlib> | |
#include<iomanip> | |
using namespace std; | |
//global variable declaration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MergeSort { | |
public void Sort(int[] arr) { | |
if (arr.length < 2) { | |
return; | |
} | |
int middle = arr.length / 2; | |
int[] left = new int[middle]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void swap(int[] arr, int index1, int index2) { | |
int temp = arr[index1]; | |
arr[index1] = arr[index2]; | |
arr[index2] = temp; | |
} | |
public static void bubbleSort(int[] arr) { | |
for (int i = 0; i < arr.length; i++) { | |
for (int j = 1; j < arr.length; j++) { | |
if (arr[j] < arr[j - 1]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() | |
{ | |
int arr[] = {10,20,-3,5,6,7,9}; | |
int size = sizeof(arr) / sizeof(arr[0]); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
void selectionSort(int arr[] , int n) | |
{ | |
int minIdx; | |
for(int i = 0 ; i < n - 1 ; i++){ | |
minIdx = i ; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int size = 0 ; | |
int sum = 0 ; | |
cout<<"Enter Size Of Array : "; | |
cin>>size; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int size = 0 ; | |
int sum = 0 ; | |
cout<<"Enter Size Of Array : "; | |
cin>>size; | |
NewerOlder