CS50 Week 2: Arrays, Libraries, and the Power (and Struggles) of Recursion

ยท

2 min read

Hey everyone, continuing my journey through CS50's Introduction to Computer Science! As promised, I've been tackling Week 2, which delves into the world of arrays .

Almost There with Arrays and Recursion!

I'm happy to report that I've made significant progress. I've conquered concepts like arrays and various libraries, making it easier to solve array problems efficiently in C. My understanding of arrays was already solid, so navigating this section wasn't too challenging. However, C doesn't offer the same built-in features as languages like Java. For instance, finding the length of an array in Java is as simple as arr.length, but in C, you need a bit more legwork. I used a while loop that breaks when it encounters the null terminator (\0) and keeps track of the number of elements (n).

The real learning curve came with strings. I thoroughly enjoyed understanding how strings allocate memory, with the null terminator (\0) at the end signifying the string's end. It was an overall engaging and insightful lecture.

Recursion: A Fun Challenge (with a Twist)

The Data Structures and Algorithms (DSA) section introduced me to recursion, starting with pattern printing. While recursive solutions are technically possible, it's important to acknowledge that traditional for/nested loops often prove more efficient and easier to understand in this context.

Now, about those remaining challenges... Life sometimes throws unexpected curveballs, and in this case, it was a guest's arrival that temporarily derailed my completion of bubble and selection sort using recursion. But fear not! I'm determined to conquer these algorithms before tomorrow and share my progress in the next DSA blog.

Thanks for staying tuned, and see you next time!

Did you find this article valuable?

Support Pratik Kale by becoming a sponsor. Any amount is appreciated!

ย