将n个元素插入数组末尾的时间复杂度是多少? [英] What is the time complexity of inserting n elements to the end of an array?

查看:128
本文介绍了将n个元素插入数组末尾的时间复杂度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道将一个元素插入数组需要一个恒定的时间让我们说c。



我尝试了什么: <插入n元素时间= $ pre> c + c + c + ....... n次= nc






i想问一下,这将是n或o的大O(1)

解决方案

是的,这就是家庭作业问题的气味所以你不会得到一个直接的回答。



谷歌的大O符号,你会发现很多信息和例子。



哦,软件开发工作的一个重要部分是研究。你要么自己学习如何做,要么你将成为这个行业的初学者。


i know that inserting an element to an array takes a constant time let us say c.

What I have tried:

for inserting n element time=

c+c+c+.......n times =nc


i want to ask that will it be big O of n or o(1)

解决方案

Yeah, this smells of a homework question so you're not going to get a direct answer.

Google for "Big O notation" and you'll find plenty of information and examples.

Oh, a HUGE part of the job of software development is RESEARCH. You either learn how to do it on your own, or you're going to be a beginner in this business until you do.


这篇关于将n个元素插入数组末尾的时间复杂度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆