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
Which is faster arraylist or hashmap?
What is unmodifiable list?
Which sorting is best in time complexity?
Tell me what is quick sort?
What are the two traversal strategies used in traversing a graph?
Why we use linked list?
What is the difference between a Stack and a Queue.
What is nsmutablearray?
Why null is allowed in hashmap?
What stack means?
How do you find the size of an arraylist?
How does a treemap work?
What are the objectives of studying data structures?
How would you use bsearch() function to search a name stored in array of pointers to string?
What is the difference between static and dynamic data?