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가지 방법이 가장 기본적인 쿼리이다.

JAVA 이진탐색 알고리즘

이진탐색 Binarysearch


이진탐색(binary search)는 정렬되어 있는 자료들의 집합에서 특정 자료를 찾고자 할 때 많이 사용되며 매우 빠른 탐색 알고리즘이다.




이미지 출저 : http://anster.tistory.com/152

위의 그림 처럼 임의의 숫자가 가능한지 아닌지를 알아내기 쉬운 방법이다.



JAVA 코드



  
  public class Binarysearch {

      public static void main(String[] args) {

        int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        binarySearch(2, arr);

    }

    public static void binarySearch(int iKey, int arr[]) {

        int mid;
        int left = 0;
        int right = arr.length - 1;

        while (right >= left) {

            mid = (right + left) / 2;

            if (iKey == arr[mid]) {

                System.out.println(iKey + " is in the array with index value: " + mid);

                break;

            }

            if (iKey < arr[mid]) {

                right = mid - 1;

            } else {

                left = mid + 1;

            }
         }

    }
}

  

댓글

이 블로그의 인기 게시물

3계층 구조( 3 Tier Architecture )

GET방식과 POST방식이란? ( PHP )

MySQL Index태우기가 뭐에요?