<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: joaquinperea</title>
    <description>The latest articles on DEV Community by joaquinperea (@joaquinperea).</description>
    <link>https://dev.to/joaquinperea</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F932856%2F73198eea-4cc5-4724-a0b5-4eb5c35f3a86.png</url>
      <title>DEV Community: joaquinperea</title>
      <link>https://dev.to/joaquinperea</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joaquinperea"/>
    <language>en</language>
    <item>
      <title>How can I measure Big O complexity in a Python method?</title>
      <dc:creator>joaquinperea</dc:creator>
      <pubDate>Mon, 26 Sep 2022 18:58:27 +0000</pubDate>
      <link>https://dev.to/joaquinperea/how-can-i-measure-big-o-complexity-in-a-python-method-4226</link>
      <guid>https://dev.to/joaquinperea/how-can-i-measure-big-o-complexity-in-a-python-method-4226</guid>
      <description>&lt;p&gt;Hi everyone! Thanks for reading.&lt;br&gt;
I need to solve a problem where, first of all, I add certain number of integer values to a list called "values_added". After that, I need to implement a method called "build_stats" which prepare the data to be analyzed by another methods.&lt;br&gt;
I have this portion of code which I need to be build in a Big O complexity equals to O(n):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def build_stats(self):
        """
        Function that generates the necessary statistics structure to be consumed
        through the "stats" object.
        :return: Stats object.
        """
        self.values_added.sort()
        for i, elem in enumerate(self.values_added):
            if elem not in self.values_stats:
                self.values_stats[elem] = {
                    'left': i,
                    'right': len(self.values_added) - i - 1,
                    'count': 1
                }
            else:
                self.values_stats[elem]['right'] = len(self.values_added) - i - 1
                self.values_stats[elem]['count'] += 1
        return Stats(self.values_added, self.values_stats)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I need to check if this method has a time complexity = O(n).&lt;br&gt;
Thanks!&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>algorithms</category>
      <category>complexity</category>
    </item>
  </channel>
</rss>
