Selection, Insert, Merge, Quick Sort 구현
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

Selection, Insert, Merge, Quick Sort 구현에 대한 보고서 자료입니다.

목차

1.Selction Sort.
(1)Source
(2)Capture

2.Insert Sort.
(1)Source
(2)Capture

3.Merge Sort.
(1)Source
(2)Capture

4.Quick Sort.
(1)Source
(2)Capture

본문내용

= partition(data, first, n);
//파티션. 피봇 왼쪽 값은 피봇보다 작은값 피봇 오른쪽 값은 피봇보다 큰값
for(int m=0;m<10;++m)//중간과정 for문
System.out.print(data[m]+BLANKS); //중간과정 보여줌
System.out.println();
n1 = pivotIndex - first;
n2 = n- n1- 1;
quicksort(data,first,n1); //pivot 왼쪽 sorting
quicksort(data,pivotIndex+1,n2); //pivot 오른쪽 sorting
}
}
public static int partition(int[] data, int first, int n){
int pivot = data[first]; //첫번째 값을 pivot 값으로
int tooBigIndex = first + 1; //pivot 다음 index에서 시작
int tooSmallIndex = first + n - 1;//맨 오른쪽 index에서 시작
int temp;
while(tooBigIndex <= tooSmallIndex)
{
if((tooBigIndex + 1) == data.length) //원소의 개수가 작다면
break;
while(data[tooBigIndex] <= pivot) //pivot 보다 큰 원소를 찾음
{
if((tooBigIndex + 1) == data.length)
break;
tooBigIndex++;
}
while(data[tooSmallIndex] > pivot)
//pivot 보다 작은 원소를 찾음
tooSmallIndex--;
if(tooBigIndex < tooSmallIndex) //index가 교차 되지 않았을때
{
//pivot보다 큰값은 오른쪽으로 작은값은 왼쪽으로
temp = data[tooBigIndex];
data[tooBigIndex] = data[tooSmallIndex];
data[tooSmallIndex] = temp;
}
}
data[first] = data[tooSmallIndex];
//data[first]값과 index 교차되었을때
data[tooSmallIndex] = pivot;//tooSmallIndex값과 교환
return tooSmallIndex;//리턴
}
public static void main(String[] args){
final String BLANKS = " ";//빈칸
int i;
int[] data = new int[10];
Random random = new Random(); //Random 변수 선언
for(i=0; i<10; i++)
data[i] = random.nextInt(100); //random 수를 100으로 한정
System.out.println("Here is the original array :");
for(i=0; i System.out.print(data[i] + BLANKS);
//보기 편하기 위해 print 메소드, 정렬전
System.out.printf("\n\n");
quicksort(data,0,data.length);//quick Sort 호출
System.out.println("\nIn sorted order(Quick Sort), the numbers are : ");
for(i=0; i System.out.print(data[i] + BLANKS);//정렬후
System.out.println();
}
}
4-(2)Capture Result

키워드

Selection,   Insert,   Merge,   Quick,   Sort,   Sorting,   소트,   소팅
  • 가격1,500
  • 페이지수8페이지
  • 등록일2006.06.26
  • 저작시기2006.6
  • 파일형식한글(hwp)
  • 자료번호#356508
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니