레이블이 Algorithm인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Algorithm인 게시물을 표시합니다. 모든 게시물 표시

2019년 3월 13일 수요일

Difference between Dictionary and Hashtable

Dictionary
  1. Dictionary is generic type Dictionary<TKey,TValue>
  2. Dictionary class is a strong type < TKey,TValue > Hence, you must specify the data types for key and value.
  3. There is no need of boxing/unboxing.
  4. When you try to access non existing key dictionary, it gives runtime error.
  5. Dictionary maintains an order of the stored values.
  6. There is no need of boxing/unboxing, so it is faster than Hashtable.
Hashtable
  1. Hashtable is non-generic type.
  2. Hashtable is a weakly typed data structure, so you can add keys and values of any object type.
  3. Values need to have boxing/unboxing.
  4. When you try to access non existing key Hashtable, it gives null values.
  5. Hashtable never maintains an order of the stored values.
  6. Hashtable needs boxing/unboxing, so it is slower than Dictionary.

2017년 6월 4일 일요일

직접 만든 < 경우의 수, 플로이드(경로찾기), 클러스터링 > 자바 라이브러리


경우의 수 : 함수이름을 참고해서 예를들어 3P2 이면 매개변수를 3,2 넣어주면 됨

플로이드 : 경로를 2차원 배열로 만들어서 넘겨주면 됨

클러스터링 : 객체 생성자로 개체의 속성 갯수, 분류할 클러스터 갯수 선언

이후 노드 추가 후 클러스터링 진행

링크: https://github.com/shinseungwon/frequently


2017년 5월 19일 금요일

[Library] StringDistance(문자열 유사도) 검사하는 Library


가끔 정말 가끔, 2개의 문자열이 얼마나 비슷한지 체크해야 되는 경우가 있다.
예를 들면
1) I went to school.
2) I want to Squall.
위의 2개의 문자열이 있다고 가정할 때 2개의 문자열이 실제로 얼마나 비슷한가를
구해야하는 경우가 가끔 있다.
이때 사용하면 좋은 Library를 소개한다.
일명 SecondString이라고 불리는 Library다.
Library 관련 정보는 http://secondstring.sourceforge.net/ 사이트에 가면 얻을 수 있고
어떠한 알고리즘으로 구현되었는지는 http://secondstring.sourceforge.net/doc/iiweb03.pdf  
위의 문서를 탐독하면 알 수 있다.
문서는 영어로 작성되어 있고, 처음보는 수학기호들이 많이 존재하며, 그냥 많이 어렵다.
문자열 알고리즘을 개선하고자 함이 아니라면 그냥 Library만 가져다 쓸 것을 권장한다.
Example)
JaroWinkler jaro = new JaroWinkler();
StringDistance distanceChecker = jaro.getDistance();
double similarity =  distanceChecker.score(string1, string2);
위와 같이 사용하면 된다. score는 double값을 반환하는데 1에 가까울수록 2개의 문자열이
비슷하다는 것을 의미한다.
Class Description을 보면 이 외에도 정말 많은 기능을 제공하지만 우선 필요한 기능은 
이것뿐이다.
Go! and Coding!


이 글은 Evernote에서 작성되었습니다. Evernote는 하나의 업무 공간입니다. Evernote를 다운로드하세요.