I want Some component or circuit for detection of polarity of a temporary magnet(i.e the front portion of magnet is S pole or P pole.So if anyone knows about it please tell me.Thanks in advance.
So, if the compass needle's end that normally points to north gets attracted if you hold it near one pole of your magnet, this would be the north pole of it
Use a very small compass, they make one about 20mm diameter just for that purpose to check the poles in electric motors.
Or you could use another permanent magnet that has the poles marked on it. Like poles repel and unlike poles attract each other. If you cannot find a magnet thats marked you could mark it yourself if you suspend it on a (thin) string and see which end points north.