Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
linked list traversal
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { class singleLinkedlist { private int data; private singleLinkedlist next; public singleLinkedlist() { data = 0; next = null; } public singleLinkedlist(int value) { data = value; next = null; } public singleLinkedlist InsertNext(int value) { singleLinkedlist node = new singleLinkedlist(value); if (this.next == null) { node.next = null; this.next = node; } else { singleLinkedlist temp = this.next; node.next = temp; this.next = node; } return node; } public int DeleteNext() { if (next == null) return 0; singleLinkedlist node = this.next; this.next = this.next.next; node = null; return 1; } public void Traverse(singleLinkedlist node) { if (node == null) node = this; System.Console.WriteLine("Traversing Singly Linked List :"); while (node != null) { System.Console.WriteLine(node.data); node = node.next; } } } class Program { static void Main(string[] args) { singleLinkedlist node1 = new singleLinkedlist(100); singleLinkedlist node2 = node1.InsertNext(200); singleLinkedlist node3 = node2.InsertNext(300); singleLinkedlist node4 = node3.InsertNext(400); singleLinkedlist node5 = node4.InsertNext(500); node1.Traverse(null); Console.WriteLine("Deleting from Linked List..."); node3.DeleteNext(); node2.Traverse(null); System.Console.ReadLine(); } } } }
run
|
edit
|
history
|
help
0
random number generator
C# Events and Delegates example
11
CommandForce3
Square Integer Matrix
Rextester.Program.Main
3
Dictionary that tells which key was not present
Binary search tree - Pre-order Traversal
iui yurty