Insertion Sort

Insertion Sort is a simple sorting algorithm that build final sorted element in the array. The insertion sort give more efficient way and give more advantage than other sort like quick sort, merge sort and heap sort.  It’s specialties are : Simple More efficient ( Time Complexity O(n2) ) Only required constant amount of memory…

Data Structures : Stack

Stack is the data structure that can be logically through as Linear Data Structure. The basic implementation is called as LIFO ( Last In First Out ) way.   There are three operation can be perform in a stack data structure.  Push ( Insertion of an element ) Pop ( Deletion and return of top…

Merge Sort

//pagead2.googlesyndication.com/pagead/show_ads.js

Game Entry

***************************************************************************public class GameEntry{ public String name; public int score; public GameEntry(String n, int s){ name = n; score = s; } public String getName(){ return name; } public int getScore(){ return score; } public String toString(){ return “(“+name+”,”+score+”)”; } }**************************************************************************import java.util.Scanner;public class Scores{ public static final int maxEntries = 10; public GameEntry[] entries; public int…

Hole with Random Generator

import java.util.Scanner;public class randomHole{ String[][] holeStore; static int Ncol=5; static int Nrow=3; int token; randomHole(){ holeStore = new String[Nrow][Ncol]; for(int i=0; i<Nrow; i++){ for(int j=0; j<Ncol; j++){ holeStore[i][j] = “Free”; } } } void set_full(int row,int col){ findToken(); boolean valid_token = false; for(int i=0; i<Nrow; i++){ for(int j=0; j<Ncol; j++){ if(holeStore[i][j] == Integer.toString(token)){ set_full(row,col); }…

Hole without random

import java.util.Scanner;public class hole2{ String[][] holeStore; int Ncol=5; int Nrow=3; int token; hole2(){ holeStore = new String[Nrow][Ncol]; for(int i=0; i<Nrow; i++){ for(int j=0; j<Ncol; j++){ holeStore[i][j] = “Free”; } } } void set_full(int row,int col){ findToken(row,col); holeStore[row-1][col-1] = Integer.toString(token); } void set_Null(int row, int col){ holeStore[row-1][col-1] = “Free”; } void findHole(int token){ boolean is_found =…

Selection Sort

  these picture shows that the algorithm of the selection sort the code is below in (java)******************************************************************public class selectionSort{ public void sort(int[] A){ for(int i=0; i<A.length; i++){ int minIndex =i; for(int j=i; j<A.length; j++){ if(A[minIndex] > A[j]){ minIndex = j; } }   // Swapping the minIndex Element and first element  int temp = A[i]; A[i]…