Find First Free Position in Array in $O(\log n)$ Time Complexity

  • MHB
  • Thread starter mathmari
  • Start date
  • Tags
    Position
In summary: Yes, that would be one of the final cases. We also need to check if the first or last element of the array is INT_MAX, and handle those cases accordingly. (Nerd)In summary, we discussed different ways to find the first free position in an array in time complexity O(log n). We also explored edge cases and made suggestions for improvements to the code.
  • #36
I like Serena said:
Yep. (Nod)

When "int a = 3" is declared, local stack memory is allocated for it.
Furthermore it "hides" the "a" that was declared earlier.
When the closing brace comes by, the local stack memory is automatically released.
Afterwards, the original "a" becomes visible again. (Nerd)

Ahaa... Ok! (Muscle)I have also an other question...

When I declare 'starsystem', before the if statement, do I write it as followed??

[m] starsy_t *starsystem;[/m]

Or should I set it equal to [m]NULL[/m] ??

(Wondering)
 
Technology news on Phys.org
  • #37
mathmari said:
Ahaa... Ok! (Muscle)I have also an other question...

When I declare 'starsystem', before the if statement, do I write it as followed??

[m] starsy_t *starsystem;[/m]

Or should I set it equal to [m]NULL[/m] ??

(Wondering)

It is good practice to always set a pointer to NULL if you're not setting it to any other specific value. (Smirk)
 

Similar threads

Back
Top