recursion으로 미로찾기
미로찾기 package recursion; public class Maze { private static int N = 8; private static int[][] maze = { { 0, 0, 0, 0, 0, 0, 0, 1 }, { 0, 1, 1, 0, 1, 1, 0, 1 }, { 0, 0, 0, 1, 0, 0, 0, 1 }, { 0, 1, 0, 0, 1, 1, 0, 0 }, { 0, 1, 1, 1, 0, 0, 1, 1 }, { 0, 1, 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 1, 0, 0, 0, 1 }, { 0, 1, 1, 1, 0, 1, 0, 0 } }; private static final int PATHWAY_COLOR = 0; private static final int W..
2020. 6. 23.
recursion - 순차탐색, 이진트리탐색
명시적 설계 1) 순차 탐색 int search (int [] data, int begin, int end, int target){ if(begin > end){ return -1; }else if(target == data[begin]){ return begin; }else{ return search(data, begin+1, end, target); } } 2) 이진트리 탐색 public static int binarySearch(String[] items, String target, int begin, int end){ if(begin > end) return -1; else{ int middle = (begin+end)/2; int compResult = target.compareTo(items[..
2020. 6. 9.