Question
I need somone help me in this assignment please by C# 1. Create a Generic LinkedList and test your LinkedList by inserting and removing nodes.
I need somone help me in this assignment please by C#
1. Create a Generic LinkedList and test your LinkedList by inserting and removing nodes.
Include at least the following methods:
bool IsEmpty() (determine if your list is empty or not)
void InsertHeadNode(T headvalue) (insert a node with value headvalue to the front)
void InsertTailNode(T tailvalue) (insert a node with value tailvalue to the end)
T RemoveHeadNode () (remove the first Node and return its value)
T RemoveTailNode () (remove the last Node and return its value)
void PrintList() (print the value of all nodes in the list)
void InsertAfter (Node p, T newvalue) (insert a new node with value newvalue after node p )
void RemoveAfter (Node p ) (remove the node after node p )
Node
2. Complete the attached MyLinkedStack.cs.
Part1. Complete the MyListStack. There are four methods to be completed: Push(), Pop(), IsEmpty() and Size() .
Part2. Complete a method to evaluate postfix expressions using MyListStack. (Don't know what is postfix! Refer to my slides on Stacks in Course Documents.)
You are supposed to submit the two.cs files (for the two exercises above)
Since most of you are confused about removeatLast() method for the linked list, here is a code snippet to give you some hints. Instead of creating a doubly linked list and previous links to find the previous node, you may do the following instead to get to the second last node. This way you still create a singly linked list (less complicated)
tail = current; //create a tail node to point to the last node to be deleted
current = head; // point to the head node
//Locate the node before tail node
while (current.next != tail) // and until you come to the one before the tail node
{ current = current.next; // keep pointing to the next one in line }
tail = current; // when you've exited that loop, you've reached the one whose "next" is the tail
tail.next = null; // and that one is now the last one in the list, we've eliminated the old tail
count--;
-------------------------------------------------------------------------------------
Since most of you are confused about removeatLast() method for the linked list, here is a code snippet to give you some hints. Instead of creating a doubly linked list and previous links to find the previous node, you may do the following instead to get to the second last node. This way you still create a singly linked list (less complicated)
tail = current; //create a tail node to point to the last node to be deleted
current = head; // point to the head node
//Locate the node before tail node
while (current.next != tail) // and until you come to the one before the tail node
{ current = current.next; // keep pointing to the next one in line }
tail = current; // when you've exited that loop, you've reached the one whose "next" is the tail
tail.next = null; // and that one is now the last one in the list, we've eliminated the old tail
count--;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started