간단한사전을만드는데 어떤해싱함수가 가장좋을가요,

nidle의 이미지

간단한사전만드는데 어떤해싱함수가 가장좋을까요,,
책을 보니 몇몇개 나와있긴한데 이해안되는부분도 있고
이해된다해도 어떤것이 사전검색에 가장좋은지 몰라서요,
해싱함수의 알고리즘하고, 간단히 c언어로작성해주심안될가요,
그럼,,이만,. 좋은하루되세요.

eminency의 이미지

nidle wrote:
해싱함수의 알고리즘하고, 간단히 c언어로작성해주심안될가요,

공부삼아 gdbm을 써보세요... 라고 말씀드릴까 생각했는데 저 말을 보니 답변 드릴 생각이 싹 사라지는군요...ㅡ.ㅡ;;;

비슷한(사전관련) 질문들을 예전에도 올리신 분이죠..? 나름대로 노력하셨던 거 같은데...-_-;

하지만 작성을 직접 해 드릴 분은 아마 없을 거 같습니다.
해싱 소스는 검색해보고 하면 찾을 수 있을 겁니다...

즉... STFW -_-;;

노루가 사냥꾼의 손에서 벗어나는 것 같이, 새가 그물치는 자의 손에서 벗어나는 것 같이 스스로 구원하라 -잠언 6:5

nidle의 이미지

제가 너무 쉽게만 할려구 생각했다는 생각이 드네요,,
충고 감사합니다..

vacancy의 이미지

먼저 어떻게든 스스로 구현해보시고
미진한 부분이 있나 질문해보시면 좋을것 같네요.

Tony의 이미지

간단한 사전이라면?? 영어사전이면 첫 1개의 케릭터나 첫 2개의 케릭터를
해쉬키로 쓰는게 가장 빠르고 만만할듯 싶네요. 사전데이타라는게 크기가
뻔하니.... 뭐 한글사전이면 무조껀 첫2바이트로 잡아도 되긴할듯.....

대략 알고리즘은

fname = get_hash_filename( query[0] );
fp = popen( fname );
out = linear_search( fp );
fclose( fp );

get_hash_filename( char ch )
char tmp[5] = "*.txt";
tmp[0] = ch;
return tmp;

ㅎㅎ 무성의하군요!! sh script로 만들껄 ㅜ.ㅠ
위에분 GDBM이라뇨~~ 소잡는칼로 닭을잡긴 좀... 큭큭...

vacancy의 이미지

알파벳으로만 구성된 단어이고, 단어가 아주 많다면

저라면 hash대신 trie를 쓰겠습니다. -_-a

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.