Thought For The Day

“Life stands before me like an eternal spring with new and brilliant clothes”
Carl Gauss



The Basics of Programming: Sorting Algorithms

So far, in our programming series, we have learned the basics of writing computer programs in C, and we’ve discussed some good and bad practices in programming.  We have acquainted ourselves with data types, operators, input / output and the technique of writing functions.

Now it is time to study some common groups of algorithms—well known ways of solving well known problems.  Some of these things may seem complicated and hard to understand in the beginning, but as you advance and use them often, you will notice that you are writing them almost automatically.  We will also be explaining some new data structures like stacks, priority queues, linked lists etc. which are often used in combination with these most common algorithms.

The first group we will discuss—sorting algorithms—is probably the simplest to comprehend, because it is easy to see how they’re applied in real life.  The problem of sorting a data structure—most often an array, is so common that there are hundreds of algorithms to solve it, ranging from quite simple, to complex ones like quicksort.

We will explain the two simplest (in the author’s opinion) sorting algorithms, called selection sort and bubble sort.

Selection sort

This algorithm divides the input array into two parts: the sub-array of items already sorted, and the sub-array of items remaining to be sorted that occupy the rest of the array.  The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sub-array, exchanging it with the leftmost unsorted element (putting it in sorted order), and moving the sub-array boundaries one element to the right.  Simply speaking, in each iteration it finds the minimum element (if the sorting order is increasing) and puts it in the beginning of the array, by exchanging its place with other elements.

Here is the code in C for selection sort on an array of n elements:

for (int i=0; i< n-1; ++i)

   for( int j=i+1; j<n;++j)


          if(array[i] > array[j])


               int temp = array[i];





The code segment after the if statement is usually called swapping, and we will be using it in bubble sort, too.  The swapping is necessary because, if we simply wrote

array[i] = array[j];

we would lose the value of array[i] after this line executes, and then wouldn’t be able to exchange the values of the two elements, which we are trying to do.  That is why an additional variable is used to temporarily store the result of array[i].

Bubble sort

Bubble sort is similar to selection sort in matters of complexity, and the need to exchange the values of certain elements.  But it is important to notice the difference: selection sort will compare the i-th element with the i+1, i+2 … n-th element of the array, while bubble sort will always compare two subsequent elements, and swap them if needed.

Here is the code for bubble sort:

for (int i=1; i< n-1; ++i)

   for( int j=0; j<n-1-i;++j)


          if(array[j] > array[j+1])


               int temp = array[j];






These were some common and simple sorting algorithms, used mostly on small arrays and lists.  Next time we continue with useful programming lessons, so make sure you stay tuned!

A Year after Heartbleed…

Are you familiar with Heartbleed?  If not, you’re not alone.  Research shows that one year after Heartbleed made national news, 86% of Americans haven’t heard of it.  Unfortunately, Heartbleed has been deemed one of the most “dangerous security flaws on the web,” and it’s said to have impacted over 500,000 websites.[1]  With the growing number of companies experiencing hacks and bugs, it’s more important than ever that individuals minimize their online security risks to avoid being victims of identity theft.  To do so, we recommend that you take the following steps:

  • Use a Unique Password for Every Website.  This might sound overwhelming, but it really doesn’t have to be.  Use password manager software—like LastPass—that will not only generate a unique password for you, but also store it for your protection.  
  • Install Anti-Virus/Anti-Malware Protection.  Both are important.  These protect your computer from viruses, as well as the other nefarious ways that hackers try to obtain your information like keystroke capture.
  • Don’t Fall for Phishing Scams.  Phishing emails are designed to obtain confidential information—passwords, credit card numbers, etc.—by appearing as though they come from legitimate companies.  If you receive an email suggesting that Ebay needs you to update your password, for example, contact Ebay’s customer service department to verify that the email is legitimate. 
  • Be Cautious about Sharing on Social Media.  Social media can be a treasure trove of information for criminals.  Refrain from sharing your exact birthdate, as well as any information that might be used to answer password security questions.  One soldier abroad had his bank account drained, merely from a criminal having access to his email address, name, and Facebook profile.[2]
  • Take Precautions when Using Unsecured Wi-Fi.  Public Wi-Fi networks—like the kind that you might use when traveling or at a local restaurant—are inherently dangerous because of the security risks they present.  To avoid being hacked, save sensitive browsing (i.e. visiting bank and credit card websites) for when you’re at home.  If you must use a public Wi-Fi network, check out Lifehacker’s article, How to Stay Safe on Public Wi-Fi Networks.

How to Close More Often

If you’re a salesperson, you know that the name of the game is closing.  Naturally, if you want to hone your sales skills, this area presents the most potential to increase your revenue.  So, we’ve got some suggestions from the experts that will help you become a better closer:
  • Listen.  It would seem likely that to be a good closer, you would need to have a gift for gab.  While this is important, great salespeople know that listening to a client—and finding out what he wants—helps them to close.  Take time to carefully listen to your client and find out why he is considering your product or service and what he thinks it can do for him.  Then, focus on making your close specific to what he’s told you.
  • Hone Your Communication Skills.  Do you get tongue-tied in front of clients?  This happens to everyone from time to time, but fortunately, it can be overcome.  Consider joining a local Toastmasters group or practicing closing with a colleague.  The more assured you are of your communication skills, the more confident you will feel which brings us to our next point…
  • Express Confidence.  Confident salespeople are more engaging and appear more trustworthy.  However, if you don’t feel entirely confident yet, remember that the old saying, “fake it ‘til you make it,” can get you through any closing situation.  By practicing confidence in this way, you’ll start to organically acquire more confidence.
  • Ask for the Sale.  Shockingly, studies show that 62% of salespeople fail to ask for the sale![1]  Yet by merely asking, you can significantly increase the likelihood of a successful close.  While this may seem intimidating at first, you’ll find that once you overcome your initial discomfort, your sales growth will make this tactic well worth it.

5 Simple Steps to Get Started with Twitter

Say that after examining your social media strategy, you’ve decided that it would be beneficial to start using Twitter.  But where should you begin?  Fortunately, it’s easy to start using Twitter to promote your business.  Below we offer you 5 simple steps to get you started:


  1. Determine Your Goal.  Before using Twitter, it’s important to define your goal so you can determine when your objective has been reached.  Is your goal to obtain x number of followers?  Is it your goal to increase name recognition of your brand?  Once you’ve determined your priorities, you’ll find it easier to develop a Twitter strategy.

  2. Define Your Brand.  Do you want your brand to be perceived as hip and youth-oriented?  Alternatively, maybe you’re self-employed and would like to be recognized as an authority in your field.  Once you’ve decided how you want to market yourself, you’ll have a strong idea of which types of tweets will be useful for building and promoting your brand.

  3. Create a Profile.  At this stage, you’re ready to open your Twitter account.  Upon doing so, select a Twitter name—this should be something like @FirstNameLastName or @YourCompanyName.  You’ll also want to upload an attractive, professional profile picture or a corporate logo.  Be prepared to write a brief profile about your business using keywords so people can easily find you.

  4. Build Your Network.  You now want to build your Twitter following.  We recommend using a site like Tweepi—this tool allows you to manage your followers and grow your network.  For some great advice on how you can obtain new Twitter followers with Tweetpi, check out Jeff Bullas’ article, “How to Build a Targeted Twitter Tribe of 100,000.

  5. Start Tweeting.  Oftentimes when people get started with Twitter, they aren’t sure what to tweet about.  Generally speaking, you want your tweets to be entertaining and informative; tweets that include images and videos are particularly popular.  Share interesting and relevant industry information, breaking trends, how-to’s, etc.  Fortunately, this doesn’t require you to be a fount of information—you can retweet items to your followers that you think they will find appealing.