sparc-pseudocode-example-1-search-algorithm
Sub-skill of sparc-pseudocode: Example 1: Search Algorithm (+2).
Best use case
sparc-pseudocode-example-1-search-algorithm is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Sub-skill of sparc-pseudocode: Example 1: Search Algorithm (+2).
Teams using sparc-pseudocode-example-1-search-algorithm should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/example-1-search-algorithm/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How sparc-pseudocode-example-1-search-algorithm Compares
| Feature / Agent | sparc-pseudocode-example-1-search-algorithm | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Sub-skill of sparc-pseudocode: Example 1: Search Algorithm (+2).
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Example 1: Search Algorithm (+2)
## Example 1: Search Algorithm
```
ALGORITHM: OptimizedSearch
INPUT: query (string), filters (object), limit (integer)
OUTPUT: results (array of items)
SUBROUTINES:
BuildSearchIndex()
ScoreResult(item, query)
ApplyFilters(items, filters)
BEGIN
// Phase 1: Query preprocessing
normalizedQuery <- NormalizeText(query)
queryTokens <- Tokenize(normalizedQuery)
// Phase 2: Index lookup
candidates <- SET()
FOR EACH token IN queryTokens DO
matches <- SearchIndex.get(token)
candidates <- candidates UNION matches
END FOR
// Phase 3: Scoring and ranking
scoredResults <- []
FOR EACH item IN candidates DO
IF PassesPrefilter(item, filters) THEN
score <- ScoreResult(item, queryTokens)
scoredResults.append({item: item, score: score})
END IF
END FOR
// Phase 4: Sort and filter
scoredResults.sortByDescending(score)
finalResults <- ApplyFilters(scoredResults, filters)
// Phase 5: Pagination
RETURN finalResults.slice(0, limit)
END
SUBROUTINE: ScoreResult
INPUT: item, queryTokens
OUTPUT: score (float)
BEGIN
score <- 0
// Title match (highest weight)
titleMatches <- CountTokenMatches(item.title, queryTokens)
score <- score + (titleMatches * 10)
// Description match (medium weight)
descMatches <- CountTokenMatches(item.description, queryTokens)
score <- score + (descMatches * 5)
// Tag match (lower weight)
tagMatches <- CountTokenMatches(item.tags, queryTokens)
score <- score + (tagMatches * 2)
// Boost by recency
daysSinceUpdate <- (CurrentDate - item.updatedAt).days
recencyBoost <- 1 / (1 + daysSinceUpdate * 0.1)
score <- score * recencyBoost
RETURN score
END
```
## Example 2: Design Patterns
```
PATTERN: Strategy Pattern
INTERFACE: AuthenticationStrategy
authenticate(credentials): User or Error
CLASS: EmailPasswordStrategy IMPLEMENTS AuthenticationStrategy
authenticate(credentials):
// Email/password logic
CLASS: OAuthStrategy IMPLEMENTS AuthenticationStrategy
authenticate(credentials):
// OAuth logic
CLASS: AuthenticationContext
strategy: AuthenticationStrategy
executeAuthentication(credentials):
RETURN strategy.authenticate(credentials)
---
PATTERN: Observer Pattern
CLASS: EventEmitter
listeners: Map<eventName, List<callback>>
on(eventName, callback):
IF NOT listeners.has(eventName) THEN
listeners.set(eventName, [])
END IF
listeners.get(eventName).append(callback)
emit(eventName, data):
IF listeners.has(eventName) THEN
FOR EACH callback IN listeners.get(eventName) DO
callback(data)
END FOR
END IF
```
## Example 3: Complexity Analysis
```
ANALYSIS: User Authentication Flow
Time Complexity:
- Email validation: O(1)
- Database lookup: O(log n) with index
- Password verification: O(1) - fixed bcrypt rounds
- Session creation: O(1)
- Total: O(log n)
Space Complexity:
- Input storage: O(1)
- User object: O(1)
- Session data: O(1)
- Total: O(1)
ANALYSIS: Search Algorithm
Time Complexity:
- Query preprocessing: O(m) where m = query length
- Index lookup: O(k * log n) where k = token count
- Scoring: O(p) where p = candidate count
- Sorting: O(p log p)
- Filtering: O(p)
- Total: O(p log p) dominated by sorting
Space Complexity:
- Token storage: O(k)
- Candidate set: O(p)
- Scored results: O(p)
- Total: O(p)
Optimization Notes:
- Use inverted index for O(1) token lookup
- Implement early termination for large result sets
- Consider approximate algorithms for >10k results
```Related Skills
gif-search
Search and download GIFs from Tenor using curl. No dependencies beyond curl and jq. Useful for finding reaction GIFs, creating visual content, and sending GIFs in chat.
sparc-specification
SPARC Specification phase specialist for requirements analysis, constraint identification, use case definition, and acceptance criteria creation
sparc-refinement
SPARC Refinement phase specialist for iterative improvement through TDD, code optimization, refactoring, performance tuning, and quality improvement
sparc-pseudocode
SPARC Pseudocode phase specialist for algorithm design, data structure selection, complexity analysis, and design pattern identification
sparc-architecture
SPARC Architecture phase specialist for system design, component architecture, interface design, scalability planning, and technology selection
research-literature
Systematize research and literature gathering for engineering categories — queries doc index, capability map, and standards ledger to produce structured research briefs for calculation implementation. type: reference
research-and-literature-gathering
Systematic workflow for finding, downloading, and indexing engineering literature by domain. Covers the full lifecycle: discovery via standards ledger and doc index, web search for open-access PDFs, download script generation, PDF validation, catalogue YAML creation, and handoff to the 7-phase document-index-pipeline for indexing. Use when populating a new engineering domain with reference literature or when a WRK item requires domain-specific standards and textbooks.
semantic-search-setup
Setup vector embeddings and semantic search for document collections. Use for AI-powered similarity search, finding related documents, and preparing knowledge bases for RAG systems.
doc-research-download
Repeatable workflow for domain documentation research WRKs: search for freely-available references, download PDFs via shared bash lib, catalogue into knowledge/seeds/<domain>-resources.yaml. Use when starting any WRK that collects and indexes domain reference documents. type: reference
tax-e-filing-research
Guide to directly e-filing federal Form 1120 and state franchise tax returns. Covers service comparison, cost analysis, step-by-step filing procedures, and paper filing alternatives for C-Corp entities.
user-research-synthesis
Synthesize qualitative and quantitative user research into structured insights and opportunity areas
search-strategy
Query decomposition and multi-source search orchestration for enterprise knowledge retrieval workflows