A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
What is the most interesting algorithm you know?
anonymous
 4 years ago
What is the most interesting algorithm you know?

This Question is Closed

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Can you define what you mean by interesting?

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Ok then the most interesting algorithm I know is one that I wrote. ;)

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0\begin{array}l\color{#FF0000}{\text{Nice}}\text{ }\color{#FF7F00}{\text{what}}\text{ }\color{#FFE600}{\text{does}}\text{ }\color{#00FF00}{\text{it}}\text{ }\color{#0000FF}{\text{do?}}\text{ }\color{#6600FF}{\text{When}}\text{ }\color{#8B00FF}{\text{did}}\text{ }\color{#FF0000}{\text{you}}\text{ }\color{#FF7F00}{\text{write}}\text{ }\color{#FFE600}{\text{it?}}\end{array}

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0\begin{array}l\color{#FF0000}{\text{Y}}\color{#FF0000}{\text{ }}\color{#FF7F00}{\text{o}}\color{#FF7F00}{\text{ }}\color{#FFE600}{\text{u}}\color{#FFE600}{\text{ }}\color{#00FF00}{\text{r}}\color{#00FF00}{\text{ }}\color{#0000FF}{\text{ }}\color{#0000FF}{\text{ }}\color{#0000FF}{\text{a}}\color{#0000FF}{\text{ }}\color{#6600FF}{\text{l}}\color{#6600FF}{\text{ }}\color{#8B00FF}{\text{g}}\color{#8B00FF}{\text{ }}\color{#FF0000}{\text{o}}\color{#FF0000}{\text{ }}\color{#FF7F00}{\text{r}}\color{#FF7F00}{\text{ }}\color{#FFE600}{\text{i}}\color{#FFE600}{\text{ }}\color{#00FF00}{\text{t}}\color{#00FF00}{\text{ }}\color{#0000FF}{\text{h}}\color{#0000FF}{\text{ }}\color{#6600FF}{\text{m}}\color{#6600FF}{\text{ }}\color{#8B00FF}{\text{ }}\color{#8B00FF}{\text{ }}\color{#FF0000}{\text{:}}\color{#FF0000}{\text{ }}\color{#FF7F00}{\text{}}\color{#FF7F00}{\text{ }}\color{#FFE600}{\text{D}}\color{#FFE600}{\text{ }}\end{array}

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0\begin{array}l\color{#FF0000}{\text{Y}}\color{#FF7F00}{\text{o}}\color{#FFE600}{\text{u}}\color{#00FF00}{\text{r}}\color{#0000FF}{\text{ }}\color{#0000FF}{\text{f}}\color{#6600FF}{\text{a}}\color{#8B00FF}{\text{v}}\color{#FF0000}{\text{o}}\color{#FF7F00}{\text{r}}\color{#FFE600}{\text{i}}\color{#00FF00}{\text{t}}\color{#0000FF}{\text{e}}\color{#6600FF}{\text{ }}\color{#6600FF}{\text{o}}\color{#8B00FF}{\text{n}}\color{#FF0000}{\text{e}}\color{#FF7F00}{\text{!}}\end{array}

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0They are all interesting to me.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0\begin{array}l\color{#FF0000}{\text{The}}\text{ }\color{#FF7F00}{\text{only}}\text{ }\color{#FFE600}{\text{algorithm}}\text{ }\color{#00FF00}{\text{I've}}\text{ }\color{#0000FF}{\text{ever}}\text{ }\color{#6600FF}{\text{written}}\text{ }\color{#8B00FF}{\text{is}}\text{ }\color{#FF0000}{\text{this}}\text{ }\color{#FF7F00}{\text{one}}\text{ }\color{#FFE600}{\text{I'm}}\text{ }\color{#00FF00}{\text{using}}\text{ }\color{#0000FF}{\text{to}}\text{ }\color{#6600FF}{\text{color}}\text{ }\color{#8B00FF}{\text{my}}\text{ }\color{#FF0000}{\text{words}}\text{ }\color{#FF7F00}{\text{:(}}\end{array}

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Okay, in 1980 I designed and coded a game that was subsequently ripped off by a major arcade game producer. I was writing it one a Vic20. It was a sidescroller with a vehicle that could jump. I had to come up with an algorithm that kept all of the sprites in sync while on the ground, but followed each other like a train when jumping. Later I added an algorithm to add a somewhat similar effect while it was on the ground to simulate bumpy terrain.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0compared to my textcoloring algorithm, that's much cooler. Is that major arcade game producer still in business today?

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0the algorithm was actually really simple, but I was 12 at the time so I thought it was pretty genius.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0when I was 12, I didn't even know what an algorithm was :P

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0More recently, on my first foray into Java, I wrote one that put the appropriate appendix to a number (1st, 2nd, 3rd, 4th, etc.). Before the haters start flaming me, I know that is really easy, trivial, and NO BIG DEAL, but since it was not a requirement of the assignment and I was the only one in the class that even thought to do it, I was pretty proud of myself.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0so if I type in "42" it appends "nd" to the end?

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0hmm... let's try doing it in C!

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0The trick is doing the check during your parse routine.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0http://ideone.com/aJRon So in C, this will be a parsing loop that will include a step checking the last character in the string

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0i'm not too good with parsing though :(

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0I don't know enough C to help you there.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Right; although C syntax is very similar to Java, string handling in both languages is very very different anyway :(

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Yeah I figured. Seems that way with most languages that are direct derivatives of each other.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0that appendix algorithm isn't so trivial in C :(

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Well it didn't seem trivial when I first came up with it, but looking back it really wasn't that hard, but isn't that always the way it is?

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0http://ideone.com/FIUgO so that's it in C++. Time to try it in C :D

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0I think you can actually do it without parsing. It just happened that the numbers that I wanted to append were parsed strings. Let me look at my old code and see what I can come up with.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0This is an interesting exercise in C :)

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0What you have looks about right. Does it work?

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0So now see if you can do it without parsing.

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Should be able to do it with math. I'm trying to figure out the formula now.

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0What's so funny. I wait. I know. I'm a geek. Tell me something I don't already know.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I think we might be able to use the bitwise operations and stuff to do it... or maybe the modulo operator.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0http://ideone.com/IuM5n there we go

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Yeah that's what I was thinking. If Number % 10 = 1 then sNumber = Number + "st" and so forth.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I don't like '11st' or '12nd' or '13rd' though... how do we fix those cases?

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Yes I believe i have a check in there for those numbers.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0http://ideone.com/0enJt fixed

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I think the C version is easy to do now :D

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0See. Told you it was trivial. ;)

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0hmm.... but my code won't do it properly if you give it something like 111 or 112 or 113 :(

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Actually my java version is all on one line except for the check. resultsArea.append(horRule + yearCount + (yearCount == 1 ? "st" : (yearCount == 2 ? "nd" : (yearCount == 3 ? "rd" : "th"))) + " year\n");

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0because you are only checking 1113.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0right.... how do I fix it?

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0but it will break if I give it a bigger number like 1111 or 1112 :D

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0See I didn't even have to think that far because we were dealing with a program where all of my parsed numbers were < 100

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0so in order for me to make it work for arbitrary numbers, I must use strings?

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0No shouldn't. I know this is calculable.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0http://ideone.com/G1Ydb so the string version is now working correctly.

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Nice. That's one solution. I still think it's calculable. But I'm going to have to ponder it when I'm in math mode. I've been in writing mode all morning.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I shall ask this one in the Math section :D I'm sure someone will answer it

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0I'm going to try to figure it out, but post your solution on ideone when you have it.

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0No I think mod 100 will work. Show me how it breaks.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0you're right... it works!

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0112 mod 100 = 12 1112 mod 100 = 12 11112 mod 100 = 12 ad infinitum

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Who says you can't learn anything from trivial things?

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0See no that we know this if we EVER encounter a similar situation we will already be a step toward the solution.

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0This is why I believe there is no such thing as a 'stupid question'

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0nice conversation guys! most interesting algorithm? Hmmm I think my favorite one will be written in 2012 by myself :)

jagatuba
 4 years ago
Best ResponseYou've already chosen the best response.0Yeah this was one of the more enlightening conversations that I've had lately. It's nice that i was able to walk away with something from it. I nominated agdgdgdgwngo "Best Question Asker" at the OS party because he always asks good questions. Okay well not always (what is a computer?).

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0I've thinking of asking a question like this for a couple of days, i'm more interested in interesting data structures though =) some algorithms i've found interesting are A* BellmanFord max flow min cost max flow they have quite a few uses

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0A* is interesting because it's relatively old algorithm (first described in 1968, but a simpler form of it was proposed by Dijkstra in 1959), but very long lived  it's still the gold standard for path finding. Pretty much any video game uses A* or a variant of it for AI pathfinding to this day!

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0i read only beginning but java is more similar to c++ than c :P thats why its hard to play with strings in c
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.