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
Does array sort mutate?
What is height balanced tree?
What is the difference between a Stack and a Queue.
Why do we need a data structure?
What are linked lists most commonly used for?
Explain the difference between a list and array.
What are the operations that can be performed on a stack?
Is treemap thread safe?
What is link list in data structure?
Describe the height term in a tree.
Which type of memory allocation is referred for linked list?
Tell me the difference between the character array and a string.
How would you swap the Kth node from beginning with Kth node from end in a Linked List.
Does hashtable allow null values?
what is the difference between dynamic as well as non - dynamic data structures.