/* * Split.java * * Created on March 17, 2008, 1:20 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package split; /** * * @author suchenek */ public class Split { public static void main(String[] args) { // TODO code application logic here int[] Array; int N, K = 6; // para for the number of insertions cnt.clr(); //counts enqueue's cnt2.clr(); //counts cost of Stretch cnt3.clr(); //counts dequeue's cnt4.clr(); //counts cost of Shrink { N = K*15; Array = new int[N]; for (int i = 0; i < N; i++) Array[i] = i + 1; Test(Array); for (int i = 0; i < N; i++) System.out.print(Array[i] + " "); System.out.println(" End array"); System.out.print("T(" + N +")"); cnt.out(" = "); System.out.println(" " + (N) + " = N"); System.out.print("Avg. cost of Stretch per enque S(" + N +")"); System.out.println(" = " + (1.0*cnt2.get()/cnt.get())); System.out.print("Avg. cost of Shrink per deque T(" + N +")"); System.out.println(" = " + (1.0*cnt4.get()/cnt3.get())); } } public static void Test(int[] A) { int n = A.length; QUEUE Q = new QUEUE(); Q.showAll(); for (int m = 0; m*15 < n; m++) { for (int i = 0; i < 15; i++) { Q.enqueue(A[i + m*15]); A[i + m*15] = 0; } for (int i = 0; i < 13; i++) { A[i + m*13]=Q.dequeue(); } } } }