Saturday, September 17, 2016

Algorithms: Usually Helpful Programs.

In my class recently we have been learning about algorithms and how they are used in computer programming.

Our textbook, "The Pattern on the Stone" by W. Daniel Hillis, describes algorithms as a "fail safe procedure, guaranteed to achieve a specific goal"(78). He described how his roommate devised an algorithm to sort his socks properly instead of just finding two socks and if they don't match he throws them back. In this new method he pulls them out one by one and puts them in a line, and if he finds two socks that are the same he takes them from the line and folds them together.

 I've recently been looking at algorithms, both good and bad, and found one that has really peaked my interest. It is called the Bogosort algorithm (shotgun sort, monkey sort and stupid sort are also names for this algorithm) and it is the most ridiculous algorithm I have ever seen. It is incredibly ineffective as a computer program or even in real life as it randomly sorts data until they are in the correct order. Say you have a deck of cards and you wish to sort them in order. Using bogosort, you'd basically throw them in the air and pick up the cards at random, then you'd check the new shuffled deck and if it was not in order you'd toss them again and again until they were perfectly sorted. If it were written as a computer program it would look somewhat like this:

while not inOrder(deck)
      shuffle(deck)

The algorithm itself has an average case of (n-1)n! (where n is the number of tries), so the number of attempts to sort it far out numbers the number of comparisons it makes. It only checks a couple of comparisons, no matter how large the list, before just shuffling the whole list again. However because this is an algorithm, there is a very small chance that this shuffling could sort these in the correct order, although that would take a horribly long time.

It is hilariously ridiculous, and honestly the worst algorithm I've ever seen.
Bogosort can be traced back to 1984 and is written in "The New Hacker's Dictionary" [7] as ".... It serves as a sort of canonical example of awfulness. Looking at a program and seeing a dumb algorithm, one might say 'Oh, I see, this program uses bogo-sort'". So even in the Hacker Dictionary it is known as one of the worst algorithm/programs out there.

A similar algorithm is the Bozo sort. It deals with a list of random numbers and if these numbers are not in order, the program will swap two of these numbers at random and then check again to see if its sorted and it continues on such as the Bogosort. With these kinds of programs the best you can hope for is that the lists are already sorted ahead of time or else this program could take forever to figure itself out.

I do not know if anyone has tried this method of sorting with a deck of cards, and  I imagine it would be incredibly time consuming and tedious. If just one card was out of place they would have to toss the whole deck again and pick it back up in a random order. I personally do not want to waste days of my life trying to sort anything by this algorithm.

I got most of my resources from this Wikipedia article https://en.wikipedia.org/wiki/Bogosort and http://www.hermann-gruber.com/pdf/fun07-final.pdf for some more information on Bogosort.

Sunday, September 4, 2016

A Little About Myself

My name is Anna and I am a Computer Science major at K-state university. My computer class has asked us to write a blog during the semester. This first post is just a little about myself and why I am at K-state University. 
I am originally from Prairie Village, Kansas and chose K-state because of their great engineering program and because I have family in the area around Manhattan. I originally took a few years at a local community college for credits and also to find what I really wanted to do with myself after college.
My interest in Computer Science came from my father who is a programmer. I've also really liked working with computers, even when I was little and just playing computer games. I did not know I wanted to go into this career until my first year of community college. When I was in high school I thought I could be an art major, but that wouldn't really get me anywhere.
Being a Computer Science major, my hobbies do include being on my laptop and my phone. I also have a few PC games on my laptop as well. I like other things besides computers. I love to draw and paint, which is why I contemplated being an art major for a bit. I also love planting and caring for succulent plants. With my father being allergic to all flowers and most plants, I found that I love succulents because they are all pretty in a different way and very easy to take care of.
Other then my father who is a programmer, my mother is a librarian and my brother volunteers at a rest home. We also have two dogs, one a Labrador Retriever and the other a mutt. 
My first real job was a local drug store near my house. It was family owned and I became very close with my coworkers. It was near a richer part of the neighborhood so sometimes the clientele could be pretty rude and demanding. It really was a great first job though. 
My plan after college is not all that glamorous, just get a job and a house after graduation. I would like to work in programming and maybe work my way up to management but it is up in the air right now. I do think I am going to stay in Kansas, or at least around the Kansas City area. I think there are a lot of good jobs around the area, even though I don't know specifically what I want to do.
Looking through the textbook, Patterns On The Stone, and the chapter titles, one that catches my eye is the title "Beyond Engineering". I like to think about how computer science impacts the rest of the world and not just the world of engineering. I would like to hear the authors thoughts on this topic. 
Another chapter is "Computers That Learn And Adapt", which just sounds interesting. I like the current technology that is coming out with robots that can adapt to their surroundings so I am wondering if the chapter is a little bit like that.
I am going to be honest, I don't look up a lot of news about the current technology. I usually get some news from Facebook or other sites that people find interesting. An example would be my father posted an article from http://www.iflscience.com about an amputee who got a robotic arm with a drone and its incredibly interesting. So in short I usually stumble upon articles about some of the latest tech, I usually don't go looking for it, which I should.