MySQL datetime 날짜로 select하기
MySQL datetime 날짜로 select하기 select 컬럼명 from 테이블명 where date(컬럼명)='2018-01-23'; select 컬럼명 from 테이블명 where 컬럼명 between '2018-01-20' and '2018-01-24'; 위의 2가지 방법이 가장 기본적인 쿼리이다.
= (log n+log(n-1)+...+log 2)
= (log n+log(n-1)+...+log 2)+(log n+log(n-1)+...+log 2)
= O(n*log n)
public class JAVAHeap{
public static void main(String[] args) {
int[] arr = { 69, 10, 30, 2, 16, 8, 31, 22 };
HeapSort(arr);
}
public static void HeapSort(int[] arr) {
JAVAHeap heap = new JAVAHeap();
for (int i = 0; i < arr.length; i++) {
heap.insertHeap(arr[i]);
}
for (int i = arr.length - 1; i >= 0; --i) {
arr[i] = heap.deleteHeap();
}
System.out.println("힙 정렬");
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
private int heapSize;
private int itemHeap[];
public JAVAHeap() {
heapSize = 0;
itemHeap = new int[50];
}
public void insertHeap(int item) {
int i = ++heapSize;
while ((i != 1) && (item > itemHeap[i / 2])) {
itemHeap[i] = itemHeap[i / 2];
i /= 2;
}
itemHeap[i] = item;
}
public int getHeapSize() {
return this.heapSize;
}
public int deleteHeap() {
int parent, child;
int item, tmp;
item = itemHeap[1];
tmp = itemHeap[heapSize--];
parent = 1;
child = 2;
while (child <= heapSize) {
if ((child < heapSize) && (itemHeap[child] < itemHeap[child + 1]))
child++;
if (tmp >= itemHeap[child])
break;
itemHeap[parent] = itemHeap[child];
parent = child;
child *= 2;
}
itemHeap[parent] = tmp;
return item;
}
}
댓글
댓글 쓰기