Skip to main content

Objective-C Algorithms and Data Structures

Over the years I have accumulated a lot of interesting code in my repositories from different research and side projects I’ve been involved with.  A lot of this code is based in C, C++, and Objective-C, but ultimately has never see the light of day just because it was scrapped as part of a larger project or a feature being deprecated.  Last week I was looking through my old Objective-C archives and realized that I have some pretty interesting examples of general computer science algorithms that I have never shared with my blog audience.  And that is why I wanted to write this article, to share with you (my blog audience) some of the recent Objective-C algorithm examples that I recently posted in the tutorial section of my website and to give a brief overview of each section.  I hope you Enjoy!

NOTE: These algorithms have been ported over from old projects to new terminal applications in macOS Mojave.  Xcode 10 and macOS Mojave should not be required to run these examples, any recent combination of Xcode and macOS should work.


Sorting Algorithms 🗄

Sorting is a key part or organizing and searching data that I feel developers take for-granted.  After all, nowadays we have modern APIs to help us out and sometimes I feel that that these foundational sorting techniques get lost in the growth of Computer Science.  In the sorting tutorials listed below, I have included 3 examples of sorting; quick sort, merge sort, and insertion sort.  Each with their own use case and own set of pitfalls.  As an example, quick sort is said to use less memory and can be finely tuned by altering how the pivot index works even though it’s time complexity is worse than merge sort.  Merge sort is said to be a better choice when sorting large sets or data or sets that may contain custom objects. Insertion sort is said to be a good choice for very small sets of data where time complexity is not a factor and the code can be easier to grasp.

  1. Quick Sort:
  2. Merge Sort:
  3. Insertion Sort:


Searching and Data Structures 🗂

Now that your data is sorted it’s time to search your data.  In my examples I posted a binary search example created on a custom built binary tree data structure. These links will instruct you on how to build out a custom binary tree data structure and then instruct you on how to traverse the tree looking for data.   Each have their own applications, but I prefer the binary search due to the code surface area it take to set up a tree data structure.

  1. Binary Tree Data Structure:
  2. Binary Tree Search:


In Summary ⌛️

In summary, I’m glad I found these old Objective-C algorithms and was able to post them as tutorials.  I think they serve as a great resource for anyone exploring more about fundamental computer science algorithms and how they are implemented in the Objective-C programming language.  I know I loved writing Objective-C and I hope there are developers outside of large companies that still use it today.   If you enjoyed any of these tutorial and want to see the C/C++ versions I also have in my archives, let me know and I can post them as well.  Thanks for reading and if you have any questions comments or concerns, please leave a comment and I will get back to you as soon as I am able to.

Member for

3 years 9 months
Matt Eaton

Long time mobile team lead with a love for network engineering, security, IoT, oss, writing, wireless, and mobile.  Avid runner and determined health nut living in the greater Chicagoland area.