Skip to content

알고리즘 감지 시스템 개선 및 예제 추가#108

Merged
Danto7632 merged 2 commits intomainfrom
dongjun1
Oct 22, 2025
Merged

알고리즘 감지 시스템 개선 및 예제 추가#108
Danto7632 merged 2 commits intomainfrom
dongjun1

Conversation

@yoon1017
Copy link
Copy Markdown
Contributor

🎯 알고리즘 감지 시스템 개선 및 예제 추가

📝 변경 사항 요약

  • Selection Sort, Insertion Sort, Factorial 예제 추가
  • AnimationFactory 감지 로직 강화
  • VisualizationModal이 Factory 감지 로직 활용하도록 리팩토링
  • 중복 코드 제거 및 유지보수성 향상

🗂️ 수정된 파일

새로 추가된 파일

  • src/components/ide/mockData/codeExamples/selectionSort.js
  • src/components/ide/mockData/codeExamples/insertionSort.js
  • src/components/ide/mockData/codeExamples/factorial.js
  • src/components/ide/mockData/jsonExamples/selectionSort.json
  • src/components/ide/mockData/jsonExamples/insertionSort.json
  • src/components/ide/mockData/jsonExamples/factorial.json

수정된 파일

  • src/components/ide/mockData/index.js
  • src/components/ide/visualization/AnimationFactory.js
  • src/components/ide/visualization/VisualizationModal.jsx

🔍 주요 개선 내용

1. 새로운 알고리즘 예제 추가

  • Selection Sort: 선택 정렬 알고리즘 코드 및 JSON 데이터
  • Insertion Sort: 삽입 정렬 알고리즘 코드 및 JSON 데이터
  • Factorial: 재귀 기반 팩토리얼 코드 및 JSON 데이터

2. AnimationFactory 감지 로직 강화

  • 재귀 패턴 감지 개선: call/return 균형 분석으로 재귀 감지 정확도 향상
  • 정렬 알고리즘 세부 분석: Selection/Insertion/Bubble Sort 구분 로직 추가
    • Selection Sort: swap 비율이 낮음 (라운드당 1번)
    • Insertion Sort: 연속 swap 패턴 (삽입 위치까지 밀어내기)
    • Bubble Sort: compare 직후 swap (인접 원소 교환)

3. VisualizationModal 리팩토링

  • 중복된 detectAlgorithmFromEvents 함수 제거
  • AnimationFactory.detectAnimationType() 직접 활용
  • 단일 책임 원칙 준수 (감지 로직은 Factory가 담당)

4. index.js 패턴 매칭 확장

const patterns = {
    selectionSort: ['selection', '선택'],
    insertionSort: ['insertion', '삽입'],
    factorial: ['factorial', '팩토리얼', 'fact'],
    // ...
};

📊 개선 효과

  • ✅ Selection Sort, Insertion Sort, Factorial 자동 감지 가능
  • ✅ 재귀 패턴 감지 정확도 향상
  • ✅ 중복 로직 제거로 코드 라인 수 감소
  • ✅ 유지보수성 향상 (감지 로직 일원화)
  • ✅ 일관된 감지 로직 사용

🧪 테스트 방법

  1. Selection Sort 예제 로드 → 자동 감지 확인
  2. Insertion Sort 예제 로드 → 자동 감지 확인
  3. Factorial 예제 로드 → 재귀 패턴 감지 확인
  4. 기존 예제들 정상 작동 확인

📌 기술적 세부사항

AnimationFactory 감지 우선순위

  1. viz.type 명시적 지정 (최우선)
  2. ds_op.target으로 자료구조 감지
  3. call/return 패턴으로 재귀 감지
  4. compare/swap 패턴으로 정렬 알고리즘 구분
  5. 기본값 처리

재귀 감지 로직

if (callCount >= 3 && returnCount >= 3) {
    const ratio = returnCount / callCount;
    if (ratio >= 0.8 && ratio <= 1.2) {
        return 'recursion';
    }
}

Co-authored-by: Claude (Anthropic)

@Danto7632 Danto7632 merged commit 27b4bc8 into main Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants