Page 1 of 2 [ 18 posts ]  Go to page 1, 2  Next

Madbones
Veteran
Veteran

User avatar

Joined: 7 Mar 2010
Age: 27
Gender: Male
Posts: 777
Location: In the zone

16 May 2011, 3:47 am

Where can I learn how to do algorithms online?
I will be using it for programming.
So it will be for computer algorithms:
http://computer.howstuffworks.com/question717.htm



Burzum
Veteran
Veteran

User avatar

Joined: 26 Apr 2011
Age: 33
Gender: Male
Posts: 1,205

16 May 2011, 4:05 am

It kind of depends on which algorithm you want to implement... I doubt there is a site that contains documentation for every algorithm known to computing.



Madbones
Veteran
Veteran

User avatar

Joined: 7 Mar 2010
Age: 27
Gender: Male
Posts: 777
Location: In the zone

16 May 2011, 4:09 am

Burzum wrote:
It kind of depends on which algorithm you want to implement... I doubt there is a site that contains documentation for every algorithm known to computing.

Something for a voting system.
Like:
IF (submitted vote gets above: 70 and is highest}{
Show the highest scoring vote, then the second highest scoring vote thats above 70 (or random submission)
}
else{
Show any random submitted vote that scores below the highest
}



christian77
Hummingbird
Hummingbird

User avatar

Joined: 7 May 2011
Age: 47
Gender: Male
Posts: 20
Location: Germany

16 May 2011, 5:36 am

Quote:
Something for a voting system.
Like:
IF (submitted vote gets above: 70 and is highest}{
Show the highest scoring vote, then the second highest scoring vote thats above 70 (or random submission)
}
else{
Show any random submitted vote that scores below the highest
}


This problem seems to be a standard situation that involves sorting. Sorting is a subject taught in every computer science beginners class and there are several sorting algorithms available with different levels of efficiency. One of the simplest but most innefficient sort algorithms is "BubbleSort". Better algorithms are MergeSort, QuickSort or InsertionSort. The most efficient algorithm as far as I know is HeapSort in its special variation "Bottom-Up HeapSort".

The efficiency of sorting is compared by counting the number of comparisons in relation to the size of the input set. BubbleSort involves "compare every element with every other element" and therefor comes with "input-squared" efficiency.



mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 34
Gender: Male
Posts: 538
Location: Sacramento

16 May 2011, 12:50 pm

This is the classic algorithms book. You can download an ebook of it here: http://ifile.it/gysvte/ebooksclub.org__Introduction_to_Algorithms__Third_Edition.pdf

If that one seems difficult to understand at first, you might want to start with this which is what I used in my first data structures class:
http://ifile.it/d3l5u8/ebooksclub.org__Data_Structures_and_Algorithms_in_Java__4th_Edition.l_4zx37z4z7x2oxok.pdf

Also, I'll just leave this here because its cool: http://www.i-programmer.info/news/150-training-a-education/2255-sorting-algorithms-as-dances.html



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,898
Location: Over there

16 May 2011, 5:01 pm

mcg wrote:
That was fun!


_________________
Giraffe: a ruminant with a view.


ailan
Emu Egg
Emu Egg

User avatar

Joined: 13 Jun 2011
Gender: Male
Posts: 1

14 Jun 2011, 1:54 am

If you are comfortable with Java, here is an amazing source that contains downloadable example code and practice problems with solutions: ambesty dot com



ruveyn
Veteran
Veteran

User avatar

Joined: 21 Sep 2008
Age: 88
Gender: Male
Posts: 31,502
Location: New Jersey

14 Jun 2011, 6:54 am

There are also search and retrieve algorithms as well has pattern detection and matching algorithms.

Then there is the field of encryption and decryption which is probably the most difficult area of algorithmic development.

ruveyn



iceman314
Blue Jay
Blue Jay

User avatar

Joined: 10 Oct 2007
Age: 33
Gender: Male
Posts: 87
Location: West Yorkshire

14 Jun 2011, 11:37 am

Here is a basic implementation of an insertion sort (assume first is already sorted):

for(i=1;i<n;i++)
{
j=i;
value = list[i];
while((j>0) && (list[j-1]>value)){
list[j] = list[j-1];
j--;
}
list[j] = value;
}

That's just psuedocode though.


_________________
"You will soon have your God, and you will make him with your own hands."


ryan93
Veteran
Veteran

User avatar

Joined: 15 Apr 2009
Age: 31
Gender: Male
Posts: 2,315
Location: Galway, Ireland

14 Jun 2011, 12:04 pm

Quote:
Where can I learn how to do algorithms online?


Find an algorithm you would like to implement, work on it until it works, and then make it as efficient as possible?

I'd recommend starting with implementing some simple factorial algorithms, and then working your way up to dynamic programming. I'd personally recommend implementing a "longest increasing subsequence" algorithm (based on the Knuth - Robinson - Schendsted correspondence), but it really depends on what you're interested in. Basic encryption is also fun to play with.


_________________
The scientist only imposes two things, namely truth and sincerity, imposes them upon himself and upon other scientists - Erwin Schrodinger

Member of the WP Strident Atheists


LordoftheMonkeys
Veteran
Veteran

User avatar

Joined: 15 Aug 2009
Age: 35
Gender: Male
Posts: 927
Location: A deep,dark hole in the ground

14 Jun 2011, 3:49 pm

There's a pretty decent book by Niklaus Wirth called Algorithms and Data Structures. There's a free ebook for it in PDF form somewhere on the internet. It uses a lot of mathematics, but you can skip over some of the details and still get the basic idea.


_________________
I don't want a good life. I want an interesting one.


lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,795
Location: Somerset UK

15 Jun 2011, 11:14 am

LordoftheMonkeys wrote:
There's a pretty decent book by Niklaus Wirth called Algorithms and Data Structures. There's a free ebook for it in PDF form somewhere on the internet. It uses a lot of mathematics, but you can skip over some of the details and still get the basic idea.

Interesting.... I thought you had mis-titled his book, because I have "Algorithms + Data Structures = Programs" here in front of me. Wikipedia link

However, I now gather that, eleven years later, he re-vamped it:
1975 (Pascal) http://www.inf.ethz.ch/personal/wirth/b ... gorithmE0/
1986 (Modula-2) http://www.inf.ethz.ch/personal/wirth/b ... gorithmE1/

I didn't find a PDF for either book. I thought maybe it had been removed for copyright infringement.

Then I noticed that, tucked away on his home page... he has reissued it again, now using his latest language/OS:
2004 (Oberon) http://www.inf.ethz.ch/personal/wirth/ (down near then end)

Sadly, the PDF only contains the first two sections of the book.

I think I might have to look at his updated stuff. :)
http://www.ethoberon.ethz.ch/


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


LordoftheMonkeys
Veteran
Veteran

User avatar

Joined: 15 Aug 2009
Age: 35
Gender: Male
Posts: 927
Location: A deep,dark hole in the ground

15 Jun 2011, 12:35 pm

The copy I have contains five sections.
1. Fundamental Data Structures
2. Sorting
3. Recursive Algorithms
4. Dynamic Information Structures
5. Key Transformations

The appendix on the syntax of Oberon is left out.


_________________
I don't want a good life. I want an interesting one.


lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,795
Location: Somerset UK

15 Jun 2011, 4:12 pm

LordoftheMonkeys wrote:
The copy I have contains five sections.
1. Fundamental Data Structures
2. Sorting
3. Recursive Algorithms
4. Dynamic Information Structures
5. Key Transformations

The appendix on the syntax of Oberon is left out.

Fascinating. My Pascal version also has five sections.

My first four sections are named exactly the same as yours. However, the fourth section merely has a final subsection named "4.6 Key Transformations (Hashing)".

My fifth section is "Language structures and compilers", which develops the full code of a compiler for "PL/0" (a subset of Pascal).

I wonder why Wirth decided no one needed to know how to write compilers any more?


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


soulecho
Blue Jay
Blue Jay

User avatar

Joined: 27 Jul 2010
Age: 48
Gender: Female
Posts: 78
Location: Niagara Falls

15 Jun 2011, 6:17 pm

christian77 wrote:
Quote:
Something for a voting system.
Like:
IF (submitted vote gets above: 70 and is highest}{
Show the highest scoring vote, then the second highest scoring vote thats above 70 (or random submission)
}
else{
Show any random submitted vote that scores below the highest
}


This problem seems to be a standard situation that involves sorting. Sorting is a subject taught in every computer science beginners class and there are several sorting algorithms available with different levels of efficiency. One of the simplest but most innefficient sort algorithms is "BubbleSort". Better algorithms are MergeSort, QuickSort or InsertionSort. The most efficient algorithm as far as I know is HeapSort in its special variation "Bottom-Up HeapSort".

The efficiency of sorting is compared by counting the number of comparisons in relation to the size of the input set. BubbleSort involves "compare every element with every other element" and therefor comes with "input-squared" efficiency.


Wrong, the most efficient search/sort mechanism is a hash/key pair, which is O(1). Heapsort is O(nLog(n))

:wink:



mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 34
Gender: Male
Posts: 538
Location: Sacramento

15 Jun 2011, 7:41 pm

soulecho wrote:
christian77 wrote:
Quote:
Something for a voting system.
Like:
IF (submitted vote gets above: 70 and is highest}{
Show the highest scoring vote, then the second highest scoring vote thats above 70 (or random submission)
}
else{
Show any random submitted vote that scores below the highest
}


This problem seems to be a standard situation that involves sorting. Sorting is a subject taught in every computer science beginners class and there are several sorting algorithms available with different levels of efficiency. One of the simplest but most innefficient sort algorithms is "BubbleSort". Better algorithms are MergeSort, QuickSort or InsertionSort. The most efficient algorithm as far as I know is HeapSort in its special variation "Bottom-Up HeapSort".

The efficiency of sorting is compared by counting the number of comparisons in relation to the size of the input set. BubbleSort involves "compare every element with every other element" and therefor comes with "input-squared" efficiency.


Wrong, the most efficient search/sort mechanism is a hash/key pair, which is O(1). Heapsort is O(nLog(n))

:wink:
You can't sort in constant time. You can use a hash table for constant time lookup (assuming there are no collisions), but hashes are not useful for sorting.

Edit: well there are bucket-type sorts but those are linear time at best and need big data structures.