Insertion Sort 삽입정렬 Insert an element in the sorted subarray to its left. 두번째 Index를 시작으로 자신보다 앞 쪽 (왼쪽) 의 값과 계속 비교해가면서 자리를 옮겨나가는 알고리즘이다. How the Insertion array works int arr[] = [3,5,1,4,2] partial sorted subarray partial unsorted array [3] [5,1,4,2] [3,5] [1,4,2] [3,5,1] -> [3,1,5] -> [1,3,5] [4,2] [1,3,5,4] -> [1,3,4,5] [2] [1,3,4,5,2] -> [1,3,4,2,5] -> [1,3,2,4,5] -> [1,2,3,4,5] [] Solution ..
Sequential Search Algorithm (Linear Search) 순차탐색 Less used than binary search and Hash Table. Big-O notation for Sequential Search is O(n) which is relatively slower than others. public class Main { public static void main(String[] args) { int arr[] = {7, 4, 3, 1, 5}; int x = 3; int answer = linearSearch(arr, x); if(answer == -1){ System.out.println("No element matched"); }else{ System.out.print..
Selection Sort 선택정렬 Selection sort searches for the smallest element among the unsorted elements sort them in ascending order and places them in order from the first index of the array. Solution in Java public class Main { public static void main(String[] args) { int arr[] = {37, 15, 8, 22, 10}; //required {8, 10, 15, 22, 37} in ascending order. selectionSort(arr); showArr(arr); } private static..
Bubble Sort 버블정렬 맨 앞의 index부터 바로 옆의 index와 비교를 해서 큰 수가 오른쪽으로 자리하면서 더이상 비교할 값이 없을 때까지 정렬을 해나가는 알고리즘. 3 2 5 1 4 1st Pass - The largest number is placed at the last when each pass is complete. 한번의 실행마다 가장 큰 수가 가장 마지막 index 에 자리하게 된다. 2 3 1 4 5 2nd Pass 2 1 3 4 5 3rd Pass 1 2 3 4 5 Example Code in Java public class Main { public static void main(String[] args) { int arr[] = {3,2,5,1,4}; printArray(a..
Recursion in Java 재귀호출 In programming, It's common to call a method from another method. Recursion allows calling the method itself. A factorial example is a popular way to understand the basic principle of recursion. 재귀함수는 재귀를 종료시킬 조건에 부합할 때까지 자기 자신의 메서드를 계속 호출하기 때문에 종료조건에 다다르고 나서야 값을 리턴하기 시작한다. factorial 5! = 5 x 4 x 3 x 2 x 1 5! = 5 x 4! 4! = 4 x 3 x 2 x 1 4! = 4 x 3! factorial using loop pub..
Binary Search 이진탐색 Binary search uses 'divide and conquer' strategy. Binary search is fast to search for specific data by dividing the search data in half. The Array should be a sorted array Example Code I in Java public class Main { public static void main(String[] args) { int[] arr = {1,2,4,6,8,9}; //should be sorted array. binarySearch(9, arr); } public static void binarySearch(int i, int arr..
- Total
- Today
- Yesterday
- repeat()
- math.abs
- rest parameter
- easy javascript algorithm
- substring()
- hackerrank javascript solution
- java
- C++
- string class in java
- HackerRank Algorithm
- hackerrank
- 알고리즘
- 프로그래머스 알고리즘
- equals()
- Javascript Algorithm
- 프로그래머스 알고리즘문제
- Object type casting
- code refactoring
- spring boot application
- easy algorithm
- javascript
- Collection Framework
- 프로그래머스
- hackerrank javascript
- hackerrank solution
- compareTo()
- math.max
- HashMap
- algorithm
- ... in Javascript
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |