Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void deleteNode(Node<int> n, int x)
- {
- if (n.GetValue() == x)
- {
- Node<int> temp = n;
- n = n.GetNext();
- temp.SetNext(null);
- }
- else
- {
- while (n.GetNext().HasNext())
- {
- if (n.GetNext().GetValue() == x)
- {
- Node<int> temp = n.GetNext();
- n.SetNext(temp.GetNext());
- temp.SetNext(null);
- }
- n = n.GetNext();
- }
- Node<int> temp1 = n.GetNext();
- if (temp1.GetValue() == x)
- {
- n.SetNext(null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement