Sunday, October 4, 2015

Writing to an NTFS drive from a Mac

If you have ever tried to write to an NTFS drive from a Mac, you may have been frustrated. NTFS is sometimes chosen over FAT32 since it support files larger than 4GB. However, a common misconception is that Macs cannot write to NTFS. However, this is in fact supported by Apple, you just have to know how to do it. All you need to do is add one line to your /etc/fstab file (create it if it does not exist):

LABEL=drivename none ntfs rw,auto,nobrowse

Replace with the name of the drive you are mounting. Make sure that the drive name does not contain any spaces. After editing the file, then remount the drive and you are good to go. Just a little tip for you, and for me, when I forget what I did.

Saturday, August 1, 2015

Bubble Sort Java Implementations

Out of curiosity, I decided to implement the Bubble Sort to refresh my memory, and play around with Generics. At a really high level, the bubble sort is performed by iterating over an array of elements and comparing adjacent elements. If the adjacent elements are in the wrong order, then you swap them. You continue to iterate over the array until no changes are made to the order of the elements within an iteration. This sort is essentially brute force, and not as performant as other sorts such as quick sort, merge sort, etc.

1. Here is my initial implementation which sorts the characters within a String in lexicographic order:
2. Here is my follow-up implementation which sorts a List:
3. Finally, I decided to implement a version which uses Generics to sort a List of Comparables:
4. Here are some example scenarios and output:
Example output: Thank you for reading this far through the post! If you are curious, the full code example is in GitHub here: https://github.com/jmartin127/InterviewQuestions