2. Write a program using switch statement that reads a character representing a geometrical figure, then asks the user to enter the required data (ex. Radius for a circle, length and height for a rectangle, etc. ...) . The program should then print the area and circumference.
Figures are: circle(c), square(s), rectangle(r), triangle (t).
Explain The merits of using a deque to implement a stack in data structure
Stacks are often implemented using the same node structure as a linked list.
No. A stack is a data structure that allows insertion and removal at the top. A circular list allows insertion and removal anywhere in the list. The two types of data structure are too different to be reasonably implementable in terms of each other.
I didnt get exactly what do you mean by stack class template, but this is one which implements a stack! and also shows how to implement it with templates http://thetechnofreaks.com/2011/10/26/4-creating-a-stack/#ixzz1bvq2V1Ws
Sure, recursion can always be substituted with using a stack.
Explain The merits of using a deque to implement a stack in data structure
Heap is a data-structure, it cannot implement anything. On the other hand, it is true that: 1. Recursive routines might use heap. 2. You can use dynamic memory allocation (heap), to implement a stack; and use the stack to implement recursion.
You would need an array to store the actual stack. Better use an ArrayList or some other structure that you can redimension. You'll also need a variable to point to the "top of stack" - the last element added, which is the first element to be taken away.
Stacks are often implemented using the same node structure as a linked list.
Yes it is possible to implement stack and queue using linked list
No. A stack is a data structure that allows insertion and removal at the top. A circular list allows insertion and removal anywhere in the list. The two types of data structure are too different to be reasonably implementable in terms of each other.
Stack implementations allow us to easily implement backtracking algorithms.
Stacks are primarily used to implement backtracking algorithms.
stack abstract datatype
Stack is not a way to perform quicksort, it is a tool used to implement recursion.
I didnt get exactly what do you mean by stack class template, but this is one which implements a stack! and also shows how to implement it with templates http://thetechnofreaks.com/2011/10/26/4-creating-a-stack/#ixzz1bvq2V1Ws
There is no inherent relationship between the two. It's possible to implement a stack using an array to store date, but that's about it.