본문 바로가기 메뉴 바로가기

robustflame의 블로그

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

robustflame의 블로그

검색하기 폼
  • 분류 전체보기 (15)
    • 알고리즘 이론 (6)
    • 알고리즘 문제 풀이 (9)
  • 방명록

pattern matching (1)
KMP Pattern Searching

Knuth-Morris-Pratt Pattern Searching 긴 문자열 \(A\)(길이 \(M\))에서 특정 패턴 문자열 \(B\)(길이 \(N\))가 나타나는 모든 위치를 \(O(M + N)\) 시간에 찾아내는 알고리즘이다. 구현#include using namespace std; // 문자열 A에서 문자열 B와 일치하는 위치를 모두 찾는다. vector KMPSearch(const string& A, const string& B) { int AN = A.length(), BN = B.length(); // 부분 일치 테이블 생성 vector pi(BN, 0); int matched = 0; for (int i = 1; i 0 && B[i] !..

알고리즘 이론 2017. 2. 20. 20:05
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • Data structure
  • tree
  • Segment Tree
  • suffix array
  • sliding window
  • branch and bound
  • Heap
  • divide and conquer
  • implementation
  • math
  • constructive algorithms
  • Square root decomposition
  • kmp search
  • pattern matching
  • Strings
  • karatsuba
  • BFS
  • search
  • greedy
  • sort
  • Binary search
  • Graph
  • Dynamic Programming
  • Minimum Spanning Tree
  • parametric search
  • Fenwick Tree
more
«   2025/08   »
일 월 화 수 목 금 토
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
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바