Travel Guide | All Colleges

Why I Love Computer Science;Too Many Reasons to Count.

Here’s to many more long hours of coding through the night, and sometimes beyond. Cheers!

By Bonnie Pan, Brown University

I’ve given you a list of 10 random names, and I’ve asked you to put them in alphabetical order. You take about a minute to rearrange them, and return the new list to me. “Good work,” I might say. “Now do it with a thousand more names.”

Does this seem a daunting task? Not for a computer science major! With the help of a few lines of code, this normally tiresome work becomes as simple as a click of your mouse. How is this possible? I’m going to assume that you, as a reader, have not had any exposure to the magic that is computer science, and attempt to explain one of the possible algorithms you might learn in an introductory course.

Soldier's Arch brown university image

The archway to my future…This is one of the entrances to all the techy buildings here. If you’re lucky you might be able to catch a CS major enjoying some sun; it’s kind of a rare experience for some of us.—Just kidding!

Bubble Sorting: An Example

Here is a group of numbers that I want to sort:

  • 24315.

I’m going to look at pairs of numbers in this set. So first, I look at the first pair: 24. I check to see if 2 is smaller than 4—it is. Thus, it stays in place, and my set is unchanged.

  • 24315

Now, I move on to the next pair: 43. 3 is smaller than 4, so we switch these elements to get the next group:

  • 23415

We go on to the next index and look at 41. 1 is smaller than 4, so we switch these elements as well to get:

  • 23145

4 is smaller than 5, so no change occurs.  Now that we have reached the end of the line, we do it again, starting from the first two digits.

  • 23145

2 is smaller than 3, no switch occurs.

  • 23145

3 is bigger than 1, switch it out.

  • 21345

This is the correct order—no change.

  • 21345

This is the correct order—no change. We start over from the beginning because we have reached the end of the line.

  • 21345

1 is smaller than 2, switch it out.

  • 12345

Going through the rest of the group, we see that no switches will be made, and thus, our set has been sorted!

What we have just done is called bubble sort. It is one of many methods of sorting a set of objects. What I find amazing and fun about computer science is that finishing a task, maybe as simple as sorting a list of numbers, can be encapsulated in a simple set of instructions—go through the list and switch out numbers that are in an incorrect order. This is a lot of what computer science is about—finding patterns, or algorithms, that can be repeated to manipulate a set of data. And this is only one of the many possible ways to do a task like this! There’s also merge sort, and quicksort, insertion sort, selection sort…etc. Each has its pros and cons, and it’s up to the programmer to determine which method he should use in a given situation.

(I apologize if this isn’t explained clearly enough, it’s somewhat difficult to convey computer science topics to the average layperson and I am not sure I captured the concept entirely.)

Not only is computer science flexible and rewarding to learn, it is immensely practical.

Say, for instance, you want to store a vast amount of data efficiently, with ease of accessibility and minimal clutter. You’re a medical professional, and you need to save your patients’ information with certainty and integrity. Or maybe you are an insurance company, keeping track of all your clients’ assets and rates. Or, instead, you could be a large bank, with thousands of accounts opened daily, their balances changing constantly. How do you go about this? A filing system may be messy and unreliable—papers can get lost or damaged.

Here’s another problem—once you have stored this theoretically vast amount of data, how can you manipulate it? Take, for instance, a microbiologist looking at a strand of DNA. We now have the technology to sequence nearly the entire human genome, but doing so will merely give us billions of base pairs and tens of thousands of distinct genes.

In our present time, we have access to nearly unlimited information via the amazing system of networks we call the Internet. How can we sort through and select data relevant to the topics we are interested in? In the billions of hits Google may generate for a given query, how does it determine which ones you, as its user, would find most helpful?

The way to deal with all of these questions is with computer science. It would take much, much more time and more space to write about how CS can accomplish such tasks but nothing other than a computer could possibly work out these complicated mental maneuvers efficiently enough to be worth anything.

Of course, there is a dark side to computer science—it involves a lot of frustration and many, many long, caffeinated nights. Given that, I could still go on and on about how amazing—and important—computer science is. So here’s to many more long hours of coding through the night, and sometimes beyond. Cheers!

brown university computer science image

Where computer science dreams come true.

Beini Pan

Brown University | 4 stories

I was born in Shanghai and I moved to the United States because my parents got accepted to grad school. After, my mom got a job in Washington so we moved there. 14 years later, I got into the best college ever and packed my stuff up for Providence, Rhode Island!

2 responses to “Why I Love Computer Science;Too Many Reasons to Count.”

  1. mar5000k says:

    Any other sorting algorithm?

    • collegetourist says:

      There are plenty of other sorting methods, however Beini has given a great example of a simple method here for those not as familiar with coding. Thanks for your comment.

Leave a Reply to collegetourist Cancel reply

Your email address will not be published. Required fields are marked *

You Might Also Like

Products We Love