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
How to sort 1 million floating point numbers?
Can constructor be static?
Why is data structure used?
How would you dynamically allocate a one-dimensional and two-dimensional array of integers?
How does a selection sort work for an array?
How many passes does bubble sort need?
Define an equivalence relation?
What is adt example?
How can you insert a node in a random location of the linked list?
What is the Role of push() and pop() method?
How does hashset work internally in java?
What’s the difference between enumeration and iterator interfaces?
Which interfaces are implemented by printerstatereasons?
Which interfaces are implemented by abstractsequentiallist?
Explain what is the bucket size, when the overlapping and collision occur at same time?