News for hackers. Stuff that matters.

Ask HN: Does anyone else struggle with arrays?

I find it difficult to implement low-level array-based algorithms and data structures (sort, queues, stacks, etc.) from scratch, even though I'm proficient at software development in general. Is this a common thing?
( 9 comments | 2 points | on HN )
Re:Ask HN: Does anyone else struggle with arrays? by PaulHoule on Wednesday November 16, 2022 @07:53PM (#33633427)
Definitely it is easy to mistake 𝘪 for 𝘪+1 (or is it 𝘪-1?)
Re:Ask HN: Does anyone else struggle with arrays? by shrthnd on Wednesday November 16, 2022 @08:11PM (#33633579)
Which is more efficient?
Re:Ask HN: Does anyone else struggle with arrays? by PaulHoule on Wednesday November 16, 2022 @08:40PM (#33633812)
It is not so much as which is efficient as which is correct. Implementing many algorithms it is easy to pick the wrong one which is most problematic when it gives answers that are almost right.

Pro tip. Unit tests are super effective for algorithms that are tricky. Write some simple test cases and understand how they work using the debugger.

Re:Ask HN: Does anyone else struggle with arrays? by superchroma on Wednesday November 16, 2022 @08:06PM (#33633549)
Generally, pretty efficient implementations of such should be already provided in most core libraries along with the data structures in question.

Are you practicing for l33tcode or something?

Re:Ask HN: Does anyone else struggle with arrays? by DumbArray on Wednesday November 16, 2022 @08:25PM (#33633684)
Yeah, this question was prompted by leetcode lol <grimaces>
Re:Ask HN: Does anyone else struggle with arrays? by badpun on Thursday November 17, 2022 @04:21AM (#33636641)
If you've never programmed in a lower-level language before, then it's a new skill that you have to build from the ground-up. Just keep practicising and you'll get better quickly - it's not that hard.
Re:Ask HN: Does anyone else struggle with arrays? by joshxyz on Thursday November 17, 2022 @04:24AM (#33636656)
yep to this day and age i still google how to array sorr in javascript.
Re:Ask HN: Does anyone else struggle with arrays? by _448 on Thursday November 17, 2022 @05:43AM (#33637183)
Could you be more specific what you find difficult? That will help others provide you with guidance.
Re:Ask HN: Does anyone else struggle with arrays? by pacerier on Thursday November 17, 2022 @10:35AM (#33640354)
No. In the good old times, "software development" was not overloaded to mean everything/anything.