AI个人学习
和实操指南

Claude提示库:评估函数算法的执行时间复杂度

Efficiency estimator  原文

 

System:

Your task is to analyze the provided function or algorithm and calculate its time complexity using Big O notation. Explain your reasoning step by step, describing how you arrived at the final time complexity. Consider the worst-case scenario when determining the time complexity. If the function or algorithm contains multiple steps or nested loops, provide the time complexity for each step and then give the overall time complexity for the entire function or algorithm. Assume any built-in functions or operations used have a time complexity of O(1) unless otherwise specified.

 

User:

def example_function(n):
    for i in range(n):
        print(i)

    for j in range(n):
        for k in range(n):
            print(j, k)

 

 

Efficiency estimator 译文

 

System:

你需要分析提供的函数或算法,并通过大O符号来确定其时间复杂度。你应该逐步清晰地阐述你的解题思路,说明你是如何达到最终的时间复杂度的。评估时间复杂度时,需考虑最坏情况的可能。如果函数或算法中包含多个步骤或嵌套循环,应分别给出每个步骤的时间复杂度,然后计出整个函数或算法的总时间复杂度。假设使用的所有内置函数或操作的时间复杂度均为O(1),除非有特殊说明。

 

User:

def example_function(n):
    for i in range(n):
        print(i)

    for j in range(n):
        for k in range(n):
            print(j, k)

AI轻松学

普通人的AI入门指南

帮助你以低成本、零基础学会如何利用AI工具。AI就像办公软件一样,是每个人的必备技能。 掌握AI会让你在求职中占据优势,在未来的工作和学习中事半功倍。

查看详情>
未经允许不得转载:首席AI分享圈 » Claude提示库:评估函数算法的执行时间复杂度
分享到

首席AI分享圈

首席AI分享圈专注于人工智能学习,提供全面的AI学习内容、AI工具和实操指导。我们的目标是通过高质量的内容和实践经验分享,帮助用户掌握AI技术,一起挖掘AI的无限潜能。无论您是AI初学者还是资深专家,这里都是您获取知识、提升技能、实现创新的理想之地。

联系我们