Can somebody please explain to me the internal implementation of HTML getElementById() method ? Is it traversing whole DOM tree to find the specified element or is it intelligen
That depends. The method is implemented by each web browser vendor, so the details may be different from one to another and possibly from one version of a browser to another.
I'd suggest taking a look at the source code for a browser such as Mozilla Firefox and see if you can find the implementation.