Kinect for Windows SDK Hardware and Software Requirements

Unlike other Kinect libraries, the Kinect for Windows SDK, as its name suggests, only runs on Windows operating systems. Specifically, it runs on x86 and x64 versions of Windows 7. It has been shown to also work on early versions of Windows 8. Because Kinect was designed for Xbox hardware, it requires
roughly similar hardware on a PC to run effectively.

Hardware Requirements
• Computer with a dual-core, 2.66-GHz or faster processor
• Windows 7–compatible graphics card that supports Microsoft DirectX 9.0c
• 2 GB of RAM (4 GB or RAM recommended)
• Kinect for Xbox 360 sensor
• Kinect USB power adapter
Use the free Visual Studio 2010 Express or other VS 2010 editions to program against the Kinect for Windows SDK. You will also need to have the DirectX 9.0c runtime installed. Later versions of DirectX are not backwards compatible. You will also, of course, want to download and install the latest version of the Kinect for Windows SDK. The Kinect SDK installer will install the Kinect drivers, the Microsoft Research Kinect assembly, as well as code samples.

Software Requirements
• Microsoft Visual Studio 2010 Express or other Visual Studio 2010 edition:
• Microsoft .NET Framework 4
• The Kinect for Windows SDK (x86 or x64):
• For C++ SkeletalViewer samples:
• DirectX Software Development Kit, June 2010 or later version:
• DirectX End-User Runtime Web Installer:

Hash Tables Vs. Binary Search Trees

This is one of my favorite programming interview questions: “What’s the difference between Hash Tables and Binary Search Trees?”.

Hash Tables Binary Search Trees
Algorithm Keys are mapped to values by using hash functions. Hash functions transform the key to a numeric index (usually by calculating an integer value from the key first, and then applying a “modulo arraysize” operation). This index identifies an array element (“bucket”), where all corresponding values reside (values which all stem from keys with equal hash value). The key must still be looked up within the bucket, but as hashing algorithms are supposed to ensure a good hash value distribution, hence small bucket size, this lookup is very fast. The bucket array may have to be resized dynamically when a certain load factor is reached. Node-based tree data structure, where every node contains one record (key-only, or key and value), and has a left subtree (with smaller keys) and a right subtree (with larger keys); hence keys must be comparable. Self-balancing trees, like red-black-trees, keep their height as small as possible for fast searching and inserting.
Java Implementations Hashtable
.NET Implementations Hashtable
C++ STL Implementations std::unordered_map
Sorted NO YES
Range Search NO YES
Runtime Complexity Inserting: O(1) (normal case), O(N) (worst case, only with bad hash algorithm)
Searching: O(1) (normal case), O(N) (worst case, only with bad hash algorithm).
More details.
Inserting: O(log(n)) (when balanced)
Searching: O(log(n)) (when balanced)
More details.
Implementation Notes Equal objects must produce the same hash code, however unequal objects need not produce distinct hash codes. Equals() implementations must be reflexive, symmetric, transitive, consistent. More details.
.NET’s ValueType.Equals() and GetHashCode() methods are based on reflection, hence slow; you should provide your own implementation in structs.
CompareTo() implementations must be reflexive, symmetric, transitive, consistent.More details.

Check if strings are anagrams using LINQ–C#


The approach in this article shows the use of LINQ to group by array elements and comparing two strings. The underlying algorithm is the traditional approach of sorting the characters in the strings and then comparing the strings. However the more efficient implementation of anagram checking could be done by using hash tables or dictionaries.


   2: using System;

   3: using System.Collections.Generic;

   4: using System.Linq;

   5: using System.Text;


   7: namespace AnagramCheck

   8: {

   9:     public class AnagramChecker

  10:     {

  11:         public bool IsAnagram(string[] anagrams)

  12:         {

  13:             var orderGroups = anagrams.GroupBy(w => w.Trim(), new AnagramEqualityComparer());


  15:             foreach (var group in orderGroups)

  16:             {

  17:                 if (group.Count() == anagrams.Length)

  18:                 {

  19:                     return true;

  20:                 }

  21:             }

  22:             return false;

  23:         }

  24:     }


  26:     public class AnagramEqualityComparer : IEqualityComparer<string>

  27:     {

  28:         public bool Equals(string x, string y)

  29:         {

  30:             return getCanonicalString(x) == getCanonicalString(y);

  31:         }


  33:         public int GetHashCode(string obj)

  34:         {

  35:             return getCanonicalString(obj).GetHashCode();

  36:         }


  38:         private string getCanonicalString(string word)

  39:         {

  40:             char[] wordChars = word.ToCharArray();

  41:             Array.Sort<char>(wordChars);

  42:             return new string(wordChars);

  43:         }

  44:     }

  45: }

Testing a Web Method Using Sockets

You want to test a Web method in a Web service by calling the method using sockets.
First, construct a SOAP message to send to the Web method. Second, instantiate a Socket object and connect to the remote server that hosts the Web service. Third, construct a header that contains HTTP information. Fourth, send the header plus SOAP message using the Socket.Send() method. Fifth, receive the SOAP response using Socket.Receive() in a while loop. Sixth, analyze the SOAP response for an expected value(s).

            Console.WriteLine("Calling Web Method GetTitles() using sockets");
            string input = "testing";
            string soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
            soapMessage += "<soap:Envelope xmlns:xsi=\"\"";
            soapMessage += " xmlns:xsd=\"\"";
            soapMessage += " xmlns:soap=\"\">";
            soapMessage += "<soap:Body>";
            soapMessage += "<GetTitles xmlns=\"\">";
            soapMessage += "<filter>" + input + "</filter>";
            soapMessage += "</GetTitles>";
            soapMessage += "</soap:Body>";
            soapMessage += "</soap:Envelope>";
            Console.WriteLine("SOAP message is: \n");
            string host = "localhost";
            string webService = "/TestAuto/Ch8/TheWebService/BookSearch.asmx";
            string webMethod = "GetTitles";
            IPHostEntry iphe = Dns.Resolve(host);
            IPAddress[] addList = iphe.AddressList; // addList[0] ==
            EndPoint ep = new IPEndPoint(addList[0], 80); // ep =
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            if (socket.Connected)
                Console.WriteLine("\nConnected to " + ep.ToString());
                Console.WriteLine("\nError: socket not connected");
            string header = "POST " + webService + " HTTP/1.1\r\n";
            header += "Host: " + host + "\r\n";
            header += "Content-Type: text/xml; charset=utf-8\r\n";
            header += "Content-Length: " + soapMessage.Length.ToString() + "\r\n";
            header += "Connection: close\r\n";
            header += "SOAPAction: \"" + webMethod + "\"\r\n\r\n";
            Console.Write("Header is: \n" + header);
            string sendAsString = header + soapMessage;
            byte[] sendAsBytes = Encoding.ASCII.GetBytes(sendAsString);
            int numBytesSent = socket.Send(sendAsBytes, sendAsBytes.Length,   SocketFlags.None);
            Console.WriteLine("Sending = " + numBytesSent + " bytes\n");
            byte[] receiveBufferAsBytes = new byte[512];
            string receiveAsString = "";
            string entireReceive = "";
            int numBytesReceived = 0;
            while ((numBytesReceived = socket.Receive(receiveBufferAsBytes, 512,
            SocketFlags.None)) > 0)
                receiveAsString = Encoding.ASCII.GetString(receiveBufferAsBytes, 0,
                entireReceive += receiveAsString;
            Console.WriteLine("\nThe SOAP response is " + entireReceive);
            Console.WriteLine("\nDetermining pass/fail");
            if (entireReceive.IndexOf("002") >= 0 &&
            entireReceive.IndexOf("004") >= 0 &&
            entireReceive.IndexOf("005") >= 0)

.csharpcode, .csharpcode pre
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
background-color: #f4f4f4;
width: 100%;
margin: 0em;
.csharpcode .lnum { color: #606060; }