我应该考虑的memmove()O(n)或O(1)? [英] Should I consider memmove() O(n) or O(1)?

查看:159
本文介绍了我应该考虑的memmove()O(n)或O(1)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但我想计算我的算法之一的复杂性,我不知道要考虑什么复杂的的 memmove与()函数

this may be a silly question, but I want to calculate the complexity of one of my algorithms, and I am not sure what complexity to consider for the memmove() function.

你能帮帮/解释?

void * memmove ( void * destination, const void * source, size_t num );

原来是复杂度为O(NUM)或O(1)。我想这是O(NUM),但我不知道,因为我缺乏什么的引擎盖下发生的情况,现在的认识。

So is the complexity O(num) or O(1). I suppose it's O(num), but I am not sure as I lack for now the understanding of what's going on under the hood.

推荐答案

由于 memmove与的运行时间正比增加了与它移到所需的字节数,这是O(n)。

Since the running time of memmove increases in direct proportionality with the number of bytes it is required to move, it is O(n).

这篇关于我应该考虑的memmove()O(n)或O(1)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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