随笔分类 -  数据结构

摘要:public class PriorityQ { private int maxSize; private long[] queArray; private int nItems; //constructor public PriorityQ(int s){ maxSize = s; queArray = new long[maxSize]; nItems = 0; } //insert public void insert(long item){ int j; ... 阅读全文
posted @ 2013-01-26 15:50 tangrongyue 阅读(1962) 评论(0) 推荐(0)
摘要:public class Queue { private int maxSize;//数组大小 private long[] queArray; private int front;//队头 private int rear;//队尾 private int nItems;//数据项个数 //create Queue public Queue(int s){ maxSize = s; queArray = new long[s]; front = 0; rear = -1; ... 阅读全文
posted @ 2013-01-26 12:10 tangrongyue 阅读(3504) 评论(0) 推荐(0)
摘要:public class StackX { private int maxSize; private char[] stackArray; private int top; //栈构造方法 public StackX(int max){ stackArray = new char[max]; top = -1; maxSize = max; } //入栈 public void push(char ch){ stackArray[++top] = ch;//top先自增1在执... 阅读全文
posted @ 2013-01-26 10:02 tangrongyue 阅读(343) 评论(0) 推荐(0)
摘要:package com.study.dataStructure.linearList;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;//栈类public class StackX { private int maxSize; private char[] stackArray; private int top; public StackX(int max){ stackArray = new char[max]; ... 阅读全文
posted @ 2013-01-24 15:19 tangrongyue 阅读(330) 评论(0) 推荐(0)
摘要:public class StackX { private int maxSize; private long[] stackArray; private int top; public StackX(int max){ stackArray = new long[max]; top = -1;//空栈 } public void push(long j){ stackArray[++top] = j; } public long pop(){ return stac... 阅读全文
posted @ 2013-01-24 11:58 tangrongyue 阅读(5678) 评论(0) 推荐(0)
摘要:public class OrderedArray { //有序数组的二分查找; public int find(int arr[],int key){ int lowerBound = 0; int upperBound = arr.length - 1; int curIn; while(true){ curIn = (lowerBound + upperBound)/2; if(arr[curIn] == key){//找到了 return cur... 阅读全文
posted @ 2013-01-24 11:22 tangrongyue 阅读(266) 评论(0) 推荐(0)