public ArrayList<Pair> get(Pair[] set, int k, int type) {

		BinaryHeap binaryHeap = new BinaryHeap(type);

		int i = 0;

		/** Inheap the k first elements */
		for (i = 0; i < k; i++)
			binaryHeap.inHeap(kList, set[i]);

		if (type == SMALLEST) {
			/**
			 * If the next heaps.element is smaller than the priority queue top,
			 * inheap it
			 */
			for (i = k; i < set.length; i++) {
				if (set[i].p < binaryHeap.top(kList).p) {
					kList.set(0, set[i]);
					binaryHeap.swapHeapUpDown(kList,
							binaryHeap.top(kList));
				}
			}
		} else {
			/**
			 * If the next heaps.element is smaller than the priority queue top,
			 * inheap it
			 */
			for (i = k; i < set.length; i++) {
				if (set[i].p > binaryHeap.top(kList).p) {
					kList.set(0, set[i]);
					binaryHeap.swapHeapUpDown(kList,
							binaryHeap.top(kList));
				}
			}
		}

		return kList;
	}