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
What data type is array?
Explain implementation of deletion from a binary tree.
How do you find the depth of a binary tree?
an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).
What is the function of stack?
What is the best complexity of bubble sort?
Which is better hashmap or arraylist?
What is perfect binary tree?
What is data structure? Explain.
What is ascending and descending order?
What do you mean by complexity of search algorithm?
Which type of sorting is best?
What is data structure and why it is important?
What are the advantages of linked list over an array?
Why do we need to recycle?