Algorithms
Moderators:Labib, bristy1588
Can anyone suggest some useful algorithms? For example, I have just learned Dijkstra's algorithm.
If possible please give some links also.
Important: Please don't think that, Zzzz probably knows this 'easy and wellknown' algorithm, so I need not to suggest it.
If possible please give some links also.
Important: Please don't think that, Zzzz probably knows this 'easy and wellknown' algorithm, so I need not to suggest it.
Every logical solution to a problem has its own beauty.
(Important: Please make sure that you have read about the Rules, Posting Permissions and Forum Language)
(Important: Please make sure that you have read about the Rules, Posting Permissions and Forum Language)
Re: Algorithms
For fast prime number generation, learn Sieve of Eratosthenes.
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Algorithms
আমি সর্বসাকল্যে তিনটা অ্যালগো জানি...
bubble sort (i dunno quick sort, but there's a ready-made one --- qsort under stdlib.h)
prime power factorization (trial division)
binary search (& linear search too )
euclid's algorithm
আরে! চারটা হয়ে গেল!
bubble sort (i dunno quick sort, but there's a ready-made one --- qsort under stdlib.h)
prime power factorization (trial division)
binary search (& linear search too )
euclid's algorithm
আরে! চারটা হয়ে গেল!
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Algorithms
can anyone give some reference to understand time complexity? i just know what it is, haven't enough knowledge 'bout it...
Re: Algorithms
@Hadaram: Here.
I guess you probably already know this. Let me repeat again -- "Algorithm is a creative process. You will go nowhere near to achieving competency in algorithm design by trying to "understand algorithms" better." So I suggest a better way can be try to solve a problem. If you are stuck, post the problem here. I will give you appropriate references without spoiling everything. This approach is better than learning lots of algorithms is because if you know a lot of algorithms, after a while, you will start losing your ability to think "out of the box".
Some elaboration. When you see an algorithm. Ask these questions:
"What if I remove this step and replace it with something else?"
"What are the limitations of this algorithm?"
"What are the similarities between algorithm A and algorithm B?" etc.
So, here goes a problem from me:
Given an array of n natural numbers. Find the k-th element of the array. Try to make your algorithm as efficient as possible.
I guess you probably already know this. Let me repeat again -- "Algorithm is a creative process. You will go nowhere near to achieving competency in algorithm design by trying to "understand algorithms" better." So I suggest a better way can be try to solve a problem. If you are stuck, post the problem here. I will give you appropriate references without spoiling everything. This approach is better than learning lots of algorithms is because if you know a lot of algorithms, after a while, you will start losing your ability to think "out of the box".
Some elaboration. When you see an algorithm. Ask these questions:
"What if I remove this step and replace it with something else?"
"What are the limitations of this algorithm?"
"What are the similarities between algorithm A and algorithm B?" etc.
So, here goes a problem from me:
Given an array of n natural numbers. Find the k-th element of the array. Try to make your algorithm as efficient as possible.
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Algorithms
thanks for your valuable suggestions...
array[k-1] would be required element...
array[k-1] would be required element...
Re: Algorithms
Sorry for the confusion. The question asks to find the k-th smallest number from the array (all the numbers are unique)
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Algorithms
sorting the array, array[k-1]...
Re: Algorithms
Good try! So it is O(N log N) now. Can we do better?
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Algorithms
i can't find another way... let alone 'better'...