Maaf, Anda mengaktifkan Adblock pada browser anda!
Atau anda tidak mengaktifkan Javascript![ Disable Your AdBlock Please ]
Home > Algoritma dan Pemrograman

Algoritma dan Pemrograman

Pascal Triangle Algorithm example in C programming

Pascal Triangle Algorithm Pascal Triangle Algorithm example in C programming : #include <stdio.h>long fact(int);int main() { int line, i, j; printf("Enter the no. of lines: "); scanf("%d", &line); for (i = 0; i < line; i++) { for (j = 0; j < line - i - 1; j++){ printf(" "); } for (j = 0; j <= i; j++){ ...

Read More »

Selection Sort Algorithm example in Java Programming

Selection Sort Algorithm Selection Sort Algorithm example in Java programming : public class SelectionSortExample { public static int[] doSelectionSort(int[] arr) { for (int i = 0; i < arr.length - 1; i++) { int index = i; for (int j = i + 1; j < arr.length; j++) { if (arr[j] < arr[index]) { index = j; } } int ...

Read More »

Shell Sort Algorithm example in Java Programming

Shell Sort Algorithm Shell Sort Algorithm example in Java programming : public class ShellSort { private long[] data; private int len; public ShellSort(int max) { data = new long[max]; len = 0; } public void insert(long value) { data[len] = value; len++; } public void display() { for (int j = 0; j < len; j++) { System.out.print(data[j] + " ...

Read More »

Quick Sort Algorithm in Java Programming

Quick Sort Algorithm Quick Sort Algorithm example in Java Programming : public class QuickSort { public static void main(String a[]) { int i; int array[] = { 12, 9, 4, 99, 120, 1, 3, 10, 13 }; System.out.println("Quick Sortnn"); System.out.println("Values Before the sort:n"); for (i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } System.out.println(); quick_srt(array, 0, ...

Read More »

Merge Sort Algorithm in Java Programming

Merge Sort Algorithm Merge Sort Algorithm example in Java programming : public class MergeSort { private int[] array; private int[] tempMergArr; private int length; public static void main(String a[]) { int[] inputArr = { 32, 27, 51, 89, 1, 98, 9, 28, 65, 0 }; MergeSort mms = new MergeSort(); mms.sort(inputArr); for (int i : inputArr) { System.out.print(i); System.out.print(" "); ...

Read More »

Insertion Sort Algorithm in Java Programming

Insertion Sort Algorithm Insertion Sort Algorithm example in Java programming : public class InsertionSortExample { static int step = 1; public static void main(String[] args) { int[] input = { 7, 21, 91, 43, 23, 17, 34, 9, 1 }; insertionSort(input); } private static void printNumbers(int[] input) { System.out.println("Step "+step); System.out.println("-----------------------------"); step++; for (int i = 0; i < input.length; ...

Read More »

Heap Sort Algorithm in Java Programming

Heap Sort Algorithm Heap Sort Algorithm example in Java programming : public class HeapSort { public static void main(String a[]) { int i; int arr[] = { 1, 3, 4, 5, 2 }; System.out.println("nHeap Sortn---------------"); System.out.println("nUnsorted Arrayn---------------"); for (i = 0; i < arr.length; i++){ System.out.print(" " + arr[i]); } for (i = arr.length; i > 1; i--) { fnSortHeap(arr, i ...

Read More »

Bubble Sort Algorithm in Java Programming

Bubble Sort Algorithm Bubble Sort Algorithm example in Java Programming : import java.util.Scanner; class BubbleSort { public static void main(String []args) { int n, c, d, swap; Scanner in = new Scanner(System.in); System.out.println("Input number of integers to sort"); n = in.nextInt(); int array[] = new int[n]; System.out.println("Enter " + n + " integers"); for (c = 0; c < n; ...

Read More »

Binary Search Algorithm in Java programming

Binary Search Algorithm Binary Search Algorithm example in Java programming : import java.util.*;public class BinarySearch { public static void main(String[] args) { int[] intArray = new int[10]; int searchValue = 0, index; System.out.println("Enter 10 numbers"); Scanner input = new Scanner(System.in); for (int i = 0; i < intArray.length; i++) { intArray[i] = input.nextInt(); } System.out.print("Enter a number to search for: "); ...

Read More »

Fibonacci Algorithm in Java Programming

Fibonacci Algorithm example in Java programming : import java.io.*;import java.lang.*;class Fibonacci{ public static void main(String args[]) throws IOException { if(args.length == 1){ int n=Integer.parseInt(args[0]); int a=0,b=1,c=0,i=0; while(i < n) { System.out.print(c +"t"); a=b; b=c; c=a+b; i++; } } else{ System.out.println("You havent supplied the arguments: {Usage : java fibonacci 34 } to print the first 34 fibonacci numbers."); } }} OUTPUT ...

Read More »

Responsive WordPress Theme Freetheme wordpress magazine responsive freetheme wordpress news responsive freeWORDPRESS PLUGIN PREMIUM FREEDownload theme free