How I can apply SLAM algorithm in arduino robot ?? With ultrasound sensors

Please any one do this algorithm with arduino mega??

SLAM is not a single algorithm - it is a process that includes several different steps - how those steps are implemented can take many different forms, ultimately resolving (hopefully) into a solution to the SLAM problem.

Examples (open source - there are ton of other solutions out there that are proprietary):

https://openslam.org/

The greatest issue with most SLAM solutions is that they require a TON of memory (and in many cases, a fast "processor" - in quotes because you'll probably want some sort of highly parallel processing system to quickly do the vector math). Implementations can be "small" though - at least the code. This particular implementation (which was designed to use an expensive 2D laser range finder, btw):

https://openslam.org/tinyslam.html

...requires only 200 lines of code - but again, probably a ton of memory is needed (maybe if you can hack in extra RAM onto the 2560 Mega - it might be feasible), and it likely needs more than a bit of help for the vector calcs; on a regular CPU, this is probably not a big deal - the compiler can probably optimize things to allow for using multiple cores and such. Different thing on a Mega, though...

Ultimately, you need to come to grips with what SLAM really is, and how - at a high level - the various parts work (the sense/move loop, the mapping, route planning, issues with sensor and positional "noise", etc). You will need to be very familiar with probability/stats as well as linear algebra (vector and matrix math). If you aren't at least somewhat familiar with those, you are going to find yourself in strange waters.

Finally - I would suggest to you to take this free online course (takes about 6-8 weeks; possibly less depending on how you approach it):

https://www.udacity.com/course/cs373

(note - they've recently did some updates - there is a "free courseware" version that is at your own pace)

Programming is done using Python (so you need some familiarity with that language); when I took the course back in 2012, I found it explained a number of concepts in a manner that caused "aha!" moments; seriously - this course covers everything needed for a base introduction to SLAM:

1. Localization (Markov and Monte-Carlo)

2. Probability

3. Bayes Rule

4. Histogram filters

5. Kalman filters

6. Particle filters

7. Motion planning (including breadth-first, A* and dynamic programming)

8. Path "smoothing" (non-90 degree paths)

9. PID algorithm (detailing all parts, and how to optimize p, i, and d)

10. Finally - pulling it all together (Graph SLAM)

Again - I took this course; I found it very difficult (mainly due to my less-than-stellar understanding of probabilities), but very rewarding, also. I learned a ton from this course - I got the above list by reviewing my notes from that time; it was really a complex and in-depth course. I encourage you (and anyone else with an interest in learning about SLAM) to participate in it.