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 searching algorithm is best?
How does insertion sort works?
What is breadth first tree?
Evaluate the following prefix expression " ++ 26 + - 1324" (Similar types can be asked)
How do you define a set?
What are the advantage of collection classes over arrays?
What is binary tree in computer science?
Which is the parent class of abstractqueue class?
Write a Program for Delete an element from a doubly linked list.
What is the procedure to insert into a sorted array?
Explain the uses of binary tree.
What are the types of queues?
How do you sort an arraylist?
How is heap sort implemented?
Which is better hashmap or arraylist?