This file contains hidden or 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
/* Java Program to demonstrate how to use CountDownLatch, | |
Its used when a thread needs to wait for other threads | |
before starting its work. */ | |
import java.util.concurrent.CountDownLatch; | |
public class CountDownLatchDemo | |
{ | |
public static void main(String args[]) throws InterruptedException | |
{ | |
// Let us create task that is going to wait for four |
This file contains hidden or 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
// Radix sort Java implementation | |
import java.io.*; | |
import java.util.*; | |
class Radix { | |
// A utility function to get maximum value in arr[] | |
static int getMax(int arr[], int n) | |
{ | |
int mx = arr[0]; |
This file contains hidden or 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
// Java program for implementation of Heap Sort | |
public class HeapSort | |
{ | |
public void sort(int arr[]) | |
{ | |
int n = arr.length; | |
// Build heap (rearrange array) | |
for (int i = n / 2 - 1; i >= 0; i--) | |
heapify(arr, n, i); |
This file contains hidden or 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
/* Java program for Merge Sort */ | |
class MergeSort | |
{ | |
// Merges two subarrays of arr[]. | |
// First subarray is arr[l..m] | |
// Second subarray is arr[m+1..r] | |
void merge(int arr[], int l, int m, int r) | |
{ | |
// Find sizes of two subarrays to be merged | |
int n1 = m - l + 1; |
This file contains hidden or 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
// Java program for implementation of QuickSort | |
class QuickSort | |
{ | |
/* This function takes last element as pivot, | |
places the pivot element at its correct | |
position in sorted array, and places all | |
smaller (smaller than pivot) to left of | |
pivot and all greater elements to right | |
of pivot */ | |
int partition(int arr[], int low, int high) |
This file contains hidden or 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
// Java program for implementation of Insertion Sort | |
class InsertionSort | |
{ | |
/*Function to sort array using insertion sort*/ | |
void sort(int arr[]) | |
{ | |
int n = arr.length; | |
for (int i=1; i<n; ++i) | |
{ | |
int key = arr[i]; |
This file contains hidden or 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
// Java program for implementation of Bubble Sort | |
class BubbleSort | |
{ | |
void bubbleSort(int arr[]) | |
{ | |
int n = arr.length; | |
for (int i = 0; i < n-1; i++) | |
for (int j = 0; j < n-i-1; j++) | |
if (arr[j] > arr[j+1]) | |
{ |
This file contains hidden or 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
// Java program for implementation of Selection Sort | |
class SelectionSort | |
{ | |
void sort(int arr[]) | |
{ | |
int n = arr.length; | |
// One by one move boundary of unsorted subarray | |
for (int i = 0; i < n-1; i++) | |
{ |
This file contains hidden or 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
package hadoop; | |
import java.util.*; | |
import java.io.IOException; | |
import java.io.IOException; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.conf.*; | |
import org.apache.hadoop.io.*; |
This file contains hidden or 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
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.NameValuePair; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.entity.UrlEncodedFormEntity; | |
import org.apache.http.client.methods.HttpGet; |
NewerOlder