Data Structure and Algorithm applied to iOS
When asked about data structure and algorithm for an iOS development role, there is always this idea that it’s not a knowledge needed. Swift got already native data structure, right? Isn’t the rest only UI components? That’s definitely not true. Let’s step back and discuss about data structure and algorithm applied to iOS development.
If you’ve recently went through recruitment process recently, most likely you’ve been asked about data structure and algorithm. When I was younger and with less experience, those questions didn’t feel fair: first, because it’s not every day you need to implement a quick sort, second, because I was bad at it. So it’s easier to blame the question than to reflect on it.
Then over the years, working on different features in mobile development, I noticed that some complex features were actually pretty standards data structure. For instance, working on chat interface? A simple queue structure could help do all the asynchronous tasks for each message sent. Looking at a chat bot interface? That would be a linked list to make sure the user move from another part of the script through messages.
But it can be something much more simple. If you ever worked with universal link or deeplink in iOS, most likely you have playing with string parser, splitting path and extracting parameter from a simple string to display the right screen. This is actually quite basic algorithm to make sure you’ll always get it right.
It can also affect the UI components too. I’ve recently crossed a segment control paired a page controller, one should update the second as following:
- new segment control is selected, the page should be updated.
- new page is selected (let’s say by swipe), the segment control should be selected.
If you think about this feature, it’s a matter to sync two arrays, making sure a new selected index would also update the other one. When stepping back and see the actual challenge, it’s not a UI problem anymore, just a simple algorithm to match.
Last and probably the most precious advantage of being comfortable with data structure and algorithm is that it’s a transferable skill! It’s not attached to a specific language, that’s why all big companies look into it. If you meant to move to a new stack or new department, your foundations stay as strong, you would get the right mindset regardless of the spot.
All that to say, data structure and algorithm applied everywhere, included to iOS ecosystem. Being comfortable with it will help you more to identify issue, problem will look smaller and easier to resolve, something that we all wish for as software engineer.
That’s why I’m going to write more about it in the future, but meanwhile there are already great resources online, a great start is the swift algorithm club.