Module Module1
Sub Main()
myQuequeue()
myStack()
Console.ReadLine()
End Sub
Private Sub myQuequeue()
Dim theQ As New Queue
Dim dStr, frmstrArr() As String
Dim i As Integer
frmstrArr = FillArr()
For i = 0 To 25
theQ.Enqueue(frmstrArr(i) + " queue")
Next
For i = 0 To 25
dStr = theQ.Dequeue()
Console.WriteLine(dStr)
Next
End Sub
Private Sub myStack()
Dim theStack As New Stack
Dim dStr, fStr() As String
Dim i As Integer
fStr = FillArr()
For i = 0 To 25
theStack.Push(fStr(i) + " stack")
Next
For i = 0 To 25
dStr = theStack.Pop()
Console.WriteLine(dStr)
Next
End Sub
Private Function FillArr()
Dim strArr(25) As String
strArr = New String() {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
Return strArr
End Function
end module
Yes, you should, especially if it is your homework.
Explain The merits of using a deque to implement a stack in data structure
A stack is implicitly sorted by hierarchical nested order. It does not make sense to sort a stack. Do you mean a list? If so, please ask the question again.
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).
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.
Stack implementations allow us to easily implement backtracking algorithms.
stack abstract datatype
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.
int top=-1; int stack[10];
Yes it is possible to implement stack and queue using linked list
Explain The merits of using a deque to implement a stack in data structure
In order to write a program to convert stack into queue using c language you must be able to identify the proper program. Having a special certification in programing will be beneficial as well to make sure you recognize the proper queues for the programs.
chk out the following link showing you how to implement stack. Though it is a c++ implementation it may still help you. http://thetechnofreaks.com/2011/10/26/4-creating-a-stack/#ixzz1bvp8FXdb
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.
A stack is implicitly sorted by hierarchical nested order. It does not make sense to sort a stack. Do you mean a list? If so, please ask the question again.
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).
Stacks are primarily used to implement backtracking algorithms.