GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com /*
Name - Jayneel Shah
Date - 23/10/21
Topic - Application of classes in Java
Program to implement growable self sorting array(GSSArray)
*/
import java.util.*;
class GSSArray
{
private int [] arr;
private int size;
private int lastIndex = -1;
//default constructor
GSSArray(int n)
{
arr = new int[n];
size = n;
}
int i = 0;
//insert function
public void insert(int value)
{
//if size is less than defined size regular addition
if (size > i)
{
lastIndex++;
arr[lastIndex] = value;
i++;
display();
}
//if the size is more then it first increases the size and then performs addition in the array
else
{
increaseSize();
lastIndex++;
arr[lastIndex] = value;
i++;
display();
}
}
//incrase size function - it doubles the size and copie the elements of old array in the new array
private void increaseSize()
{
int[] arr1 = new int[arr.length*2];
for(int i=0;i |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |