数组空间复杂度

发布于 2024-10-07 00:12:19 字数 175 浏览 1 评论 0 原文

我有一个问题:

我有一个数组 "S" ,其中包含 n 对象。此外,每个对象都有 m 字段。 我想将其中一些保存在另一个数组中,例如 "Q" 。我想知道这个简单方法的空间复杂度是O(|Q|)

I have a question that :

I have an array "S" which has n objects in it. also each object has m fields.
I want to save some of them in the another array like "Q" . I want to know that the space complexity of this easy method is O(|Q|)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满栀 2024-10-14 00:12:19

S 的大小为 n*sum(sizeofeach(m of n))

然后假设您保存 r 对象,其中 r

q 的大小为 r*(sum(sizeofeach(r 的 m))

The size of S it is n*sum(sizeofeach(m of n))

Then suppose you save r object where r<n

The size of q it is r*(sum(sizeofeach(m of r))

街道布景 2024-10-14 00:12:19

空间复杂度是存储Q 所需的空间量。令s 为Q 中一个元素的大小,即s = 所有m 个字段的大小。空间复杂度为O(n*s)。如果所有字段的大小都相同,那么您可以说O(n*m)

The space complexity is the amount of space required to store Q. Let s be the size of one element in Q, i.e. s = size of all m fields. The space complexity is O(n*s). If all fields are the same constant size then you could say O(n*m).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文