λ¬Έμžμ—΄ μ•Œκ³ λ¦¬μ¦˜Advanced

KMP λ¬Έμžμ—΄ λ§€μΉ­

λ¬Έμžμ—΄μ—μ„œ νŒ¨ν„΄μ„ 효율적으둜 μ°ΎλŠ” Knuth-Morris-Pratt μ•Œκ³ λ¦¬μ¦˜μž…λ‹ˆλ‹€. μ‹€νŒ¨ ν•¨μˆ˜(LPS λ°°μ—΄)λ₯Ό μ‚¬μš©ν•˜μ—¬ λΆˆν•„μš”ν•œ 비ꡐλ₯Ό κ±΄λ„ˆλ›°μ–΄ O(n+m) μ‹œκ°„ λ³΅μž‘λ„λ₯Ό λ‹¬μ„±ν•©λ‹ˆλ‹€. ν…μŠ€νŠΈ 검색, DNA μ„œμ—΄ 뢄석, ν‘œμ ˆ 탐지에 ν•„μˆ˜μ μž…λ‹ˆλ‹€.

#string#pattern-matching#preprocessing#text-search

Complexity Analysis

Time (Average)

O(n + m)

Expected case performance

Space

O(m)

Memory requirements

Time (Best)

O(n)

Best case performance

Time (Worst)

O(n + m)

Worst case performance

πŸ“š CLRS Reference

Introduction to Algorithmsβ€’Chapter 32β€’Section 32.4

Presets:
Step: 1 / 0
500ms
SlowFast
Keyboard Shortcuts
Space Play/Pause← β†’ StepR Reset1-4 Speed

Real-time Statistics

Algorithm Performance Metrics

Progress0%
Comparisons
0
Swaps
0
Array Accesses
0
Steps
1/ 0

Algorithm Visualization

Step 1 of 0

Initialize array to begin

Default
Comparing
Swapped
Sorted

Code Execution

Currently executing
Previously executed

Implementation

KMP String Matching - Algorithm Vision