Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C# Write 2 classes that implement a stack with push, pop and peek operatio

ID: 3682183 • Letter: U

Question

Using C# Write 2 classes that implement a stack with push, pop and peek operations. One should be called StackL and internally should store the data in a series of Nodes as a singly linked list. The other, StackO, can use a different data structure of your choice.

Write 2 classes that implement a queue with enqueue and dequeue operatons. One should be called QueueL and internally should store the data in a C# linked list. The other, QueueO, can use a different data structure of your choice.

Write a console application to determine the time required to perform the push/pop or queue/dequeue operations on your stacks and queues. Make an instance of a C# stack and a C# queue. Get the time required to push 10,000,000 values onto each stack and then get the time required to pop 10,000,000 values from each stack. Repeat the process using the queue and dequeue operations with the queues.

Explanation / Answer

1. Using the Operations on Stack like push, pop and peek

using System;

using System.Collections;

namespace stackApplication

{

   class stackData

   {

      static void Main(string[] args)

      {

         Stack st = new Stack();

         st.Push('ABCFAR');

         st.Push('TREE');

         st.Push('house');

         st.Push('game');

         Console.WriteLine("Current stack: ");

         foreach (char c in st)

         {

            Console.Write(c + " ");

         }

         Console.WriteLine();

         st.Push('V');

         st.Push('H');

         Console.WriteLine("The next poppable value in stack: {0}", st.Peek());

         Console.WriteLine("Current stack: ");

         foreach (char c in st)

         {

            Console.Write(c + " ");

       }

         Console.WriteLine();

         Console.WriteLine("Removing values ");

         st.Pop();

         st.Pop();

         st.Pop();

         Console.WriteLine("Current stack: ");

         foreach (char c in st)

         {

            Console.Write(c + " ");

         }

      }

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote