Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How is it possible to insert different type of elements in
stack?

Answer Posted / krishan

We can use a struct containing "void * " in it and an
unsigned int to store the datatype which "void *" will store
(can be set at time of storing the value). To store a value
of any type we can dynamically allocate the space and set
the unsigned int to some pre-determined constants. Like
1 for int type.
2 for char.
3 for char string.
4 for any other type. say some user datatype.

Is This Answer Correct ?    21 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What data type is array?

874


Explain implementation of deletion from a binary tree.

917


How do you find the depth of a binary tree?

929


an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).

871


What is the function of stack?

799


What is the best complexity of bubble sort?

860


Which is better hashmap or arraylist?

953


What is perfect binary tree?

796


What is data structure? Explain.

936


What is ascending and descending order?

812


What do you mean by complexity of search algorithm?

690


Which type of sorting is best?

889


What is data structure and why it is important?

880


What are the advantages of linked list over an array?

893


Why do we need to recycle?

806