Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linked List with basic functions.
//Title of this code //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 { // Node class for the linked list public class Node { public Node next; public string data; } public class LL { private Node head; // Primary pointer for traversal; public LL() { //head.data = ""; } public void printAllNode() { Node temp = head; // if the list is empty if(head.data == null) { Console.WriteLine("Nothing to print in the list"); } else { while (temp != null) { Console.WriteLine(temp.data); temp = temp.next; } } } public void insert(string dataToAdd) { Node toAdd = new Node(); toAdd.data = dataToAdd; Node temp = head; if(head == null) { head = toAdd; } else { while(temp.next != null) { temp = temp.next; } temp.next = toAdd; } } public bool search(string toSearch) { // Function to Search the list. Node temp = head; // if the list is empty if(head.data == null) { Console.WriteLine("Nothing Found, List Is Empty"); } else { while (temp != null) { if(temp.data == toSearch) { Console.WriteLine(toSearch + " is in the list!"); return true; } temp = temp.next; } } Console.WriteLine(toSearch + " not in the list. "); return false; } public void pop(string toPop) { // Function to delete the last node. } public void delete(string toDelete) { // Function to delete something specific. } } public class Program { public static void Main(string[] args) { LL newList = new LL(); newList.insert("1st Node"); newList.insert("2nd Node"); var check = 10; while(check > 0) { char t = (char) (67+check); newList.insert(t.ToString()); check--; } newList.printAllNode(); newList.search("0"); } } }
run
|
edit
|
history
|
help
0
Main 5.4
char.IsNumber
Test
Delegate In C#
Interface
Reverse And Shift Char in String
comb sort
buble sort
hhhh
Events