Jump to content

Refresher/SDLC/Algorithms

From Wikiversity

Presentation

Construction - Part 4
Construction - Part 4
Algorithms
Data Structures
Data Structures
List of Topics
List of Topics
   
This presentation was made possible by Wikiversal/WikiverSuite, which is made possible by your donation. Thank you for your support.
This presentation was made possible by Wikiversal/WikiverSuite, which is made possible by your donation. Thank you for your support.
Data Structures
Data Structures
 Even number if (number % 2 == 0)
 
 Odd number if (number % 2 != 0)
 
 X is power of 2 if ((x != 0) && ((x & -x) == x))
 
 Middle item of a string LinkedList: mylist.ElementAt(mylist.Count/2)
 
 Regular expression in C#: Regex Replace FormatWith in correct syntax
 
 Sample recursive solution: private void ExpandNode() { foreach (TreeViewItem node in Nodes) { ExpandNode(node); } }
 
 SortedList: mySL = new SortedList(); mySL.Add(key1,value1);
 
 Hashtable: openWith = new Hashtable(); openWith.Add("txt","notepad.exe");
 
 Hashtable speed: faster than SortedList
 
 String reversal: private static string rwr(string argSource, int argLen) { if (argLen == 1) return argSource; else return rwr(argSource.Substring(1, argSource.argLength-1),--argLen) + argSource[0].ToString(); }
 
 Find duplicate value: map int array to HashTable
 
 Travelling salesman problem: a special case of the Traveling purchaser problem
 
 Traveling purchaser problem: route with minimum combined cost of purchases and travelling given marketplaces, travel costs, available goods and their prices