On the Design and Analysis of LLM-Based Algorithms