How does the rooting apps (like kingroot) roots the android phones I rooted my android kit-kat with kingroot. This process took almost 2-3 minutes and it successfully rooted.

But what is the process involved in rooting an android phone?
I want a very clear explanation,please.

I read this how does rooting work

that answer says that placing that binary files and some other things mentioned but it is a rough answer, if possible i want an example and a very very detailed explantion please.
Place any link which explains the android coding to root an android phone.
These One-Click root apps, like ol' faithful kingroot, follow a general structure for rooting. I will be using kingroot as an example.

Phase one- Detection of device - Self explanatory, really. Kingroot scans the build.prop (which it can, its mostly what you see in about phone) to grab and nab what the hell you are using. It can use other info sources too, but I don't know which (kernel, maybe)

Phase two - Exploiting - one-click apps generally follow a pattern of exploiting weaknesses in the OS to access /system directly (and freely). Malware and other infected apps/files can do this too, to gain their own root privilege. Anyway,  they use this to gain temporary root.

Phase three - Planting files - at this point, The app just injects the SU binaries and SuperUser Management apps (in the case of kingroot, itself). It often makes these apps system apps to help protect against root access loss. Anyway, the temporary root planted previously is used as leverage, which allows for the root-app to provide permanent,  system-wide root

Final phase - polishing - assuming that everything went well, all that's left is a reboot (to load the new binaries in. You may not even need a reboot, but you should anyway) and you are done!