r/AskComputerScience • u/jjrocks314 • Jan 06 '17
Programmers of Reddit. Have you ever used an algorithm you've learned to efficiently do something by hand? E.g. Sorting groceries or shoveling snow?
7
Jan 07 '17
In 2015 my french was way below average. I could not write a correct email to save my life, and i had to take a french exam. to pass the exams you i needed above an above average grade.
the exams consisted of different types of texts (news articles, ads, emails...) that you have to read and audios (dialogues, radios ads...) that you have to listen to and then choose the most relevant answer from a list of 3 to 6 answers given to you. you have about 30 seconds to read the text or listen to the audio, read all the answers and then choose the correct answer.
i practiced on old exams, but i sucked at them. i don't know how but i got the feeling that the bots that comment here on Reddit with summary bullet points of the shared news articles can help me.
i read a summary on how the algorithm that the bots use works, and then used it to practice on old exams, and tweaked it during my practice and in the end i had the best grade in the class.
the recommended way to take the exam is. Read very carefully the text or listen very carefully to the audio, read all the answers and then choose the right one, but the algorithms that i used was as :
try to read as much of the answers as possible before the audio starts playing or reading the text
start reading the text or listening to the audio
as soon as you start understanding what the text or the audio is about go back to the answers
start with a rank of 0 and for each answer, compare its context with the context of the text/audio and rank it between 0 (least relevant) and 10 (most relevant), and then compare it with the best previous ranking answer.
choose the best best ranking answer.
this algorithm, is very efficient, because you don't have to read all the text or listen to the whole audio to start answering, and you don't read all the answers more that twice, because as soon as you compare two answers you eliminate the least ranked one, and you don't have to worry about it anymore.
fast forward to the end of 2015 i had to take TOEIC, which is a similar exam but in English, i had a perfect score (995, all 200 answers are correct).
10
u/TholomewP Jan 07 '17 edited Jan 07 '17
Anytime my professors hand back exams I like to analyze their handing out algorithm. I've had professors do it by going student by student, asking their name, then searching through an unsorted stack of exams. Which is really inefficient. I figure the best way to do it in practice is to sort the exams, then spread them out on a table. Then have the students line up unsorted and then have the line walk by the table and grab their exams. I think the most optimal would be to have the students sorted also, that way everyone is just taking their exam off the top. But in practice you'd have unsorted students, since usually students are just sitting wherever.
EDIT: I've also had a professor sort the exams, then divide the alphabet by last name into intervals with equal numbers of students. He'd then ask students who's last names start within those ranges to come up to him, so students who's last names were from A-D, E-J, etc. They'd form a line and say their name, and he'd search by hand through the exams and hand them theirs. Another professor divided the exams up into four piles and invited students up, however the piles weren't sorted so that one was really inefficient. Students could "multithread" but weren't guaranteed to find their exam, so they might have to get in line for each pile.
There are a lot of things to take into account for this kind of problem, it's fun to think about.
3
u/KyleRochi Jan 07 '17
My CS prof did exactly that, she lay them alphabetically on the table and students grabbed them as they came in and left class, seemed pretty efficient, we had around 200 kids in the class so going student to student would have taken all lecture.
1
u/brtt3000 Jan 07 '17
The prof should just read names from his random stack, hand the paper to the first row and have the students pass the exams back through the lines of desks. Not sure what sort this is, maybe some sort of sieve or bucket thing.
3
Jan 07 '17
You are assuming each of your nodes have complete knowledge. In a class of 200 that's probably not true
2
u/brtt3000 Jan 07 '17
I forgot to mention the student raises a hand when his name is called and the papers are handed straight down the columns. The prof thus pre sorts and student only need to know their own name.
1
1
u/PM_ME_YOUR_PM_PHOTOS Jan 07 '17
I had a professor who would memorize the preferred seating of the students, and sort exams based on that. If there was a error in the order of students, he'd skip that student or exam and return after handing out the rest. It was pretty impressive, actually.
9
u/slasher8880 Jan 06 '17
Insertion sort while playing card games
3
Jan 06 '17
Also, seeing how other people sort things is a big "huh, maybe some of this stuff is going in" moment.
1
Jan 07 '17
As people have said, binary search is probably the most interesting algorithm with the most direct applicability, and this article reviews how it was used in the fight against Syphilis. Not only can it be used for optimal search, but if you think of a test that "searches" for a disease positive patient, it can be used to optimally test for disease.
1
u/xerxesbeat Jan 07 '17
Not an algorithm persay, but I learned the numeric position of letters in the alphabet so I could write binary quicker (001 for caps, 011 for lowercase + 5 bits) and it's insanely useful for alphabetizing stuff
That said, I still sing the song instinctively even though I know 9 < 14 is way faster
1
u/CyanMagus Jan 08 '17
For a while I was a volunteer at a political campaign, stuffing and sorting envelopes. I used quicksort.
1
u/x_Zoyle_Love_Life_x Jan 11 '17
I used levenshtein's distance scoring in an excel sheet with 40,000 rows! I'm sure levenshtein is well utilized though.
17
u/SomeoneElseIsHereNow Jan 06 '17
Nothing fancy: looking up a word in a dictionary using binary search.
I was doing it like this before I knew what binary search means.