코딩 테스트2 [c#] 깊이 우선 탐색, 너비 우선 탐색 그래프 노드 클래스 예시 public class Graph { public class Node { public int data; public List adjacent; public bool marked; public Node(int data) { this.data = data; this.marked = false; this.adjacent = new List(); } } Node[] nodes; public Graph(int size) { nodes = new Node[size]; for(int i = 0; i < size; i++) { nodes[i] = new Node(i); } } public void addEdge(int index1, int index2) { var node1 = nodes[in.. 2021. 4. 19. [c#] 선택 정렬, 퀵 정렬, 버블 정렬, 병합 정렬 구현하기 선택 정렬 재귀함수를 이용해서 앞에서 부터 하나씩 비교하면서 가장 작은 수를 찾고 바꿔주는 형식 public int[] solution_selectSort(int[] numbers) { solution_selectSort(numbers, 0); return numbers; } public void solution_selectSort(int[] numbers, int startIndex) { if (startIndex >= numbers.Length) return; // 가장 작은 수 찾기 var minIndex = startIndex; for (int i = startIndex + 1; i numbers[i]) { m.. 2021. 4. 16. 이전 1 다음