function to create a stack of given capacity .
Stack createStack ( int capacity ) { Stack stack = new Stack ( ) ; stack . capacity = capacity ; stack . top = - 1 ; stack . array = new int [ capacity ] ; return stack ; }