In stack, the element is inserted in last which should be taken out first. For example, for sequence 4, 3, 5, 2 and 1, first insert 1, 2, 3, 4 then take out 4 and 3; here stack content is 2 and 1, again insert 5 and take out 5, 2 and 1. After insertion of 5 stack content is 5, 2, 1 then take out 5, 2 and 1. At last, we got the sequence 4, 3, 5, 2 and 1.