<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">dboyle</title><subtitle type="html" /><id>http://blogs.msdn.com/b/dboyle/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/dboyle/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2013-02-20T17:43:00Z</updated><entry><title>Languages I have learned</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/04/17/languages-i-have-learned.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/04/17/languages-i-have-learned.aspx</id><published>2013-04-17T14:25:00Z</published><updated>2013-04-17T14:25:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Ok, that should more accurately read &amp;ldquo;used&amp;rdquo; or even &amp;ldquo;abused"&amp;nbsp; - as most of these have only enterd my domain when required by a job or college course. However some have been a major part of life over a much longer periods&amp;nbsp; - C++, C# and of course SQL (in some flavour) have featured heavily over the last couple of decades.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So I had the idea to write down the full list. This is just&amp;nbsp;an exercise in nostalgia, not a critique or comparison. I just got to thinking about some of the languages I have used or even seen at their peak, which are now mostly forgotten &amp;ndash; at least by me. This list will be fairly chronological, as that should help me to remember most of them.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;BASIC&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Didn&amp;rsquo;t we all start with this? I did have some limited and infrequent exposure to Commodore 64&amp;rsquo;s and the like in the mid-80&amp;rsquo;s but did not really get the bug until the seminal moment in 1989 when I first attended the Crawley College of Technology (&lt;a href="http://en.wikipedia.org/wiki/Central_Sussex_College"&gt;now the Central Sussex College&lt;/a&gt;) part-time BASIC programming course. That short (c30 hours over a couple of months) course actually landed me a job with a company called N.E.T. (&lt;a href="http://www.net.com/"&gt;now Sonus&lt;/a&gt;) configuring IDNX network topologies, and occasionally remoting into live installations to change config values using Unix shell scripts.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Turbo Pascal&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I have fond memories of a fairly powerful tool which just needed Tp.exe (on a 3.5in floppy) and an editor.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;RPG III&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Not so fond memories of report design with this one&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Lisp&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Find the mis-matched bracket &amp;ndash; that&amp;nbsp;that's&amp;nbsp;what&amp;nbsp;I mainly remember from using this&amp;nbsp;20 years ago&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Dbase IV/Clipper&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Used to develop my first commercial code, a database system for a local company which had revolutionary pop-up &amp;ldquo;windows&amp;rdquo;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;CoBOL&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I. E. D. P. (Information, Environment, Data, Processing) &amp;ndash; still etched on my mind. Thought I had left this behind at college until I worked for a bank on the nuts and bolts of mainframe/server/client communications between various apps. I had to write a couple of libraries for their Cobol system to call and they insisted I did a few days re-training to be familiar with the CoBOL devs pain.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;X86 Assembler&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Powerful stuff. Back in college this was how we wrote games and some of the open-book exams involved questions like &amp;nbsp;&amp;nbsp;&amp;ldquo;Add auto-fire to the gun&amp;rdquo; etc... Then in the early days of Windows programming this was how you saw into some libraries when debugging (the second screen was often full of it). And then in at least one contract I&amp;rsquo;ve even ended up maintaining what were known as TSR&amp;rsquo;s (Terminate and Stay Resident programs) which set up buffers and other temporary things on users HDDs on startup.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;DOS batch files&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Always and everywhere. We have all seen full build systems written in this stuff. I still write them when I need to iterate over&amp;nbsp; bunch of files &amp;nbsp;(like moving files between changelists in SD).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;C&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;The big one. Loved it at college, Then, when I got to work, I wrote my first Windows apps in it (and hand coded the resources .rc files in the Brief editor). I feel I owe this language a debt as it opened the door for most of what I do today. I still have Kelly and Pohl&amp;rsquo;s &amp;ldquo;A book on C&amp;rdquo; on my shelf here (and I&amp;rsquo;m sure Kernighan and Ritchie&amp;rsquo;s book is at home somewhere).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;C++&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I remember in the early 90s there was an funny e-mail used to do the rounds about &amp;ldquo;why C++ is like sex&amp;rdquo; and one of the lines was something like &amp;ldquo;because everybody thinks everybody else is doing it, but really most people haven&amp;rsquo;t done as much of it as you think&amp;rdquo;. And it was like that, we could not wait to get into this cool new way of coding (OOP). I eventually&amp;nbsp;did, and it became my trade.&amp;nbsp;Back during my self-employed years I titled myself a &amp;ldquo;Contract C++ dev&amp;rdquo;. I have used a few flavours of this over the years, from Ansi to Visual C++ (and MFC) &amp;nbsp;to Borland and the OWL library.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Lotus 1-2-3 macros&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Back in the day we had a full test automation suite for the 1-2-3 product, written entirely in it&amp;rsquo;s own macros. It was impressive and took quite a bit of learning, and worked.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Lotus Notes macros&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Notes was a great rapid development platform back in the 90s and this was the way to add &amp;ldquo;code-behind&amp;rdquo;. It did sometimes mean late nights using print statements to debug, but it also meant I sometimes quickly produced really useful centralised project repositories with workflows etc... (Think Sharepoint, but in 1994).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;LotusScript&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Or Lotus Basic as I think it may have once been known. This added more power to the code behind Notes databases and came with some step-through debugging capabilities.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Java&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I did my first course in Java in 1996 or 7 and I well remember the excitement over how&amp;nbsp;the web was gaining traction at that time. I even remember a discussion with other course attendees about the end of the PC, and the advent of thin client machines. I suppose we were right &amp;ndash; it just took a while longer (and reliable broadband). Anyways I have mainly only used Java on subsequent college courses (finished a Masters a couple of years ago) and I still like it &amp;ndash; if my next job was a shift to that stack I imagine I&amp;rsquo;d be nearly as happy as I currently&amp;nbsp;am on .Net.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;CL&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;When i was a C++ dev an agency once sent me for an interview. 5 minutes in the guy asked where I learned CL &amp;ndash; turns out the agency had confused either C or C++ with CL, a SQL or 4GL language from a company called &lt;a href="http://www.mbase.com.au/Products/CL4languageanddatabase/tabid/282/Default.aspx"&gt;Multibase pty&lt;/a&gt;. So I told him that I had never heard of it, but as I was just recently arrived in Australia and needed a job I asked them to give me a week to learn it. I subsequently delivered on that first project for them (Y2K compliance testing) by writing a rudimentary parser to match patterns and identify Y2K smells&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;SQL&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Like batch files this seems to have been omni present, from DB2, Oracle, Sybase to Multibase and then MS came out with their own SQL Server and it&amp;rsquo;s Express and compact version. I've probably been using MS SQL Server for the best part of a decade.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Nortel Meridian scripts&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;As I recall the Nortel Meridian Call centre server had it&amp;rsquo;s own scripting language, which allowed the use of variables to assign calls to different levels of operators depending on their skillset and that of the forwarding operator.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;JavaScript&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;While I&amp;rsquo;ve never worked as a &amp;ldquo;web developer&amp;rdquo; I have done my fair share of html parsing and that have needed&amp;nbsp;to know what the scripts are doing too. Over the last few years working with MS Dynamics CRM has required more ramping up in this area as nearly every form in every CRM solution I have ever created has required at least some Javascript (Jscript) behind it. I like it and I like that there is a ton of resources out there to help with it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;C#&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Since the first time I walked in the doors of MS as a contractor I&amp;rsquo;ve been using this (and .Net of course). Currently it&amp;rsquo;s what I use everyday &amp;ndash; I&amp;rsquo;ve even got &lt;a href="http://blogs.msdn.com/b/dboyle/archive/2013/03/27/exam-70-483-programming-in-c-5-0.aspx"&gt;the cert to prove I know it&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;VB.Net&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I don&amp;rsquo;t use this too much, but every now and then I find myself fixing or extending a tool written with it and am always glad that .Net makes it more immediately familiar than it might otherwise&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;be.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Powershell&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I don&amp;rsquo;t write any big scripts with this, but I use it from time to time to boss my O/S or that of remote machines around.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Bourne Shell, C Shell&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Infrequent use over the years when using Unix based machines&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;When I look back at this list now it actually doesn&amp;rsquo;t appear that long, considering the time frame. So now I&amp;rsquo;m thinking there may be others which I&amp;rsquo;ve forgotten (did OS/2 have a scripting language). If I do remember more, I&amp;rsquo;ll add them here.&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10411880" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Batch file" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Batch+file/" /><category term="C#" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/C_2300_/" /><category term="Programming languages" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Programming+languages/" /></entry><entry><title>Exam 70-483: Programming in C# 5.0</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/27/exam-70-483-programming-in-c-5-0.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/27/exam-70-483-programming-in-c-5-0.aspx</id><published>2013-03-27T16:11:00Z</published><updated>2013-03-27T16:11:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I took and passed this &lt;a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-483#fbid=1Z6g2DPevAD"&gt;&lt;span style="color: #0563c1;"&gt;exam&lt;/span&gt;&lt;/a&gt; this morning and am feeling quite happy with myself. It is the first of the three exams which are building blocks towards the Microsoft Certified Solutions Developer (Windows Store Apps) certification, but on it&amp;rsquo;s own it does confer Microsoft Specialist (C# 5.0 Programming) status. For more information on the MCSD see &lt;a href="http://www.microsoft.com/learning/en/us/mcsd-windows-store-apps-certification.aspx#fbid=1Z6g2DPevAD"&gt;&lt;span style="color: #0563c1;"&gt;here&lt;/span&gt;&lt;/a&gt; as you have the option of pursuing this through C# and Xaml or Javascript and Html 5.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;My route to certification&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So I have worked in C# quite a bit over the years, but have been wary of the certification exams and the specificity of their questioning. This was due to my belief that modern resources like IntelliSense and MSDN have meant that we don&amp;rsquo;t tend to memorise the specifics of the languages and frameworks with which we work anymore. There was a time when one always required books on the desk and it was natural to save that kind of slow research time by remembering API method signatures etc... whereas now I think I tend to more naturally remember concepts and then quickly look up implementation specifics when required. But earlier this year I finally got my first &lt;a href="http://blogs.msdn.com/b/dboyle/archive/2013/01/23/mcts-in-microsoft-dynamics-crm-2011-customization-and-configuration-mb2-866.aspx"&gt;&lt;span style="color: #0563c1;"&gt;certification&lt;/span&gt;&lt;/a&gt; and so my fear of specific questioning was reduced and ultimately the experience made me want to get more certs. I purchased &lt;a href="http://www.amazon.co.uk/NET-Framework-Edition-Professional-Apress/dp/1430242337"&gt;&lt;span style="color: #0563c1;"&gt;&amp;ldquo;Pro C# and the .Net 4.5 Framework&amp;rdquo;&lt;/span&gt;&lt;/a&gt; a couple of months ago and as I worked my way through it I thought now might be a good time to think about some of the programming certifications. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So although I was at that stage only half way through the big book (it&amp;rsquo;s 1400 pages) I checked out the certification paths and discovered that as an employee I could get the recommended training course (&lt;a href="http://www.microsoft.com/learning/en/us/Course.aspx?ID=20483B&amp;amp;Locale=en-us#fbid=1Z6g2DPevAD"&gt;&lt;span style="color: #0563c1;"&gt;Course 20483B&lt;/span&gt;&lt;/a&gt;) documentation soft copy for free. Over the last few weeks in the evenings I worked through the modules and was pleasantly suprised to find no surprises; what I mean by this is that is I had pretty much covered everything in the course before (the fact that I&amp;rsquo;ve written a few &lt;a href="http://www.windowsphone.com/en-ie/search?q=dermotb"&gt;&lt;span style="color: #0563c1;"&gt;Windows Phone&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://apps.microsoft.com/windows/app/irish-tides/7d36b364-0523-4bcf-8c32-97d3f445f731"&gt;&lt;span style="color: #0563c1;"&gt;Windows 8&lt;/span&gt;&lt;/a&gt; apps over the last year certainly &amp;nbsp;helped with the newer stuff).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;After I finished the course I went ahead and booked the exam, and then revised by following the links from the blog pages of a couple of folk who had already passed it (Thank you &lt;a href="http://www.jayway.com/2012/08/15/msdn-study-links-for-exam-70-483-programming-in-c/"&gt;&lt;span style="color: #0563c1;"&gt;Andreas Hammar&lt;/span&gt;&lt;/a&gt;, &lt;a href="http://www.claudiobernasconi.ch/2013/01/15/microsoft-70-483-exam-preparation-guide/"&gt;&lt;span style="color: #0563c1;"&gt;Claudio Bernasconi&lt;/span&gt;&lt;/a&gt; and of course &lt;a href="http://en.csharp-online.net/MSDN_Reference_Guide_for_Exam_70-483"&gt;&lt;span style="color: #0563c1;"&gt;MSDN&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://social.technet.microsoft.com/Forums/en-US/CertGeneral/thread/1ae3ad77-1e36-40e2-8b1b-0bc5b766f938"&gt;&lt;span style="color: #0563c1;"&gt;Technet&lt;/span&gt;&lt;/a&gt;). I also speed read the course modules again, but paid extra attention to the areas to areas to which&amp;nbsp;I have had less exposure&amp;nbsp;(Performance counters, Reflection, using unmanaged code and encryption/decryption).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;On the day I actually found this exam a little easier than the previous CRM one - I think in programming subjects it might be easier to spot definitively correct answers. It was also&amp;nbsp;shorter (at only 40 questions) and I found&amp;nbsp;that&amp;nbsp;sometimes when I'd marked a question for review a later question which included&amp;nbsp;a code sample might help clear up the ambiguity (in my mind) and let me go back an finish the "marked for review" question (only happened for a couple of questions).&amp;nbsp;Anyway,&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I am now a certified Microsoft Specialist in C# 5.0 programming and have already acquired the course materials for the the next one (&lt;a href="http://www.microsoft.com/learning/en/us/course.aspx?ID=20484A#fbid=1Z6g2DPevAD"&gt;&lt;span style="color: #0563c1;"&gt;Essentials of Developing Windows Store Apps using C#&lt;/span&gt;&lt;/a&gt;). I&amp;rsquo;m on vacation next week, so I may get to make a start on it...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10405764" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Windows 8" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Windows+8/" /><category term="Windows Phone" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Windows+Phone/" /><category term="MCTS" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/MCTS/" /><category term="Certification" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Certification/" /><category term="Microsoft Specialist" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Microsoft+Specialist/" /><category term="C#" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/C_2300_/" /><category term=".Net" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/-Net/" /></entry><entry><title>Detecting repeated parameter values across multiple method calls</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/11/detecting-specified-parameter-patterns-in-repeated-method-calls.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/11/detecting-specified-parameter-patterns-in-repeated-method-calls.aspx</id><published>2013-03-11T13:03:00Z</published><updated>2013-03-11T13:03:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So this was actually asked of me once in an "interview&amp;nbsp;style" situation and it took me quite a while to twig that the use of a queue would&amp;nbsp;be required. I can't fully remember the wording of the question but it was basically something like this: "For every thousand session requests&amp;nbsp;recieved by your server, if the same IP address appears 3 times, then flag it as&amp;nbsp;a possible problem/hacker address".&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So as I mentioned&amp;nbsp;the use of a queue is the key to this implementation, as&amp;nbsp;controlling the queue size allows us to restrict ourselves to the most recently pased&amp;nbsp;1000 (or any other limit number) values. In real life I would probably use something&amp;nbsp;more like this &lt;a href="http://stackoverflow.com/questions/5852863/fixed-size-queue-which-automatically-dequeues-old-values-upon-new-enques"&gt;implementation for a fixed size queue&lt;/a&gt;&amp;nbsp;but right now&amp;nbsp;I've just knocked up something quick and dirty which is not thread safe etc... But it&amp;nbsp;illustrates the general logic.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I'm using a&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/7977ey2c.aspx"&gt;generic queue&lt;/a&gt; of strings&amp;nbsp;(in real life I could probably use the &lt;span class="selflink"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/s128tyf6.aspx"&gt;System.Net.IPAddress&lt;/a&gt; class) and to keep the count (up to 3) of times a address appears in each thousand I use a Dictionary implementation&amp;nbsp;with the IP address strings as my keys. So the logic is:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;For each IP address passed, add it to the queue&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;If the queue has more than 1000 items, remove the oldest one&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Upon removal of an address from the queue, also decrement the "per thousand" count associated with it in the Dictionary (if this is 0 or less, ralso emove the dictionary entry)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Upon addition of an address to the queue, also increment the "per thousand" count associated with it in the Dictionary (if this is no entry, add it with a count value of 0)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;and the code works out as:&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;code class="cplusplus"&gt; private static bool IsSuspectIP(string address)&lt;br /&gt; {&lt;br /&gt; addressQueue.Enqueue(address);&lt;br /&gt; &lt;br /&gt; if (addressQueue.Count() &amp;gt; 999)&lt;br /&gt; {&lt;br /&gt; string oldAddr = addressQueue.Dequeue();&lt;br /&gt; DecrementCounter(oldAddr);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; IncrementCounter(address);&lt;br /&gt; &lt;br /&gt; if (addressCounters[address] &amp;gt;= 2)&lt;br /&gt; {&lt;br /&gt; return true;&lt;br /&gt; }&lt;br /&gt; return false;&lt;br /&gt; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;code class="cplusplus"&gt; private static void IncrementCounter(string address)&lt;br /&gt; {&lt;br /&gt; if (addressCounters.ContainsKey(address))&lt;br /&gt; {&lt;br /&gt; addressCounters[address]++;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; addressCounters.Add(address, 0);&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;code class="cplusplus"&gt; private static void DecrementCounter(string address)&lt;br /&gt; {&lt;br /&gt; if (addressCounters.ContainsKey(address))&lt;br /&gt; {&lt;br /&gt; if (addressCounters[address] &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt; addressCounters.Remove(address);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; addressCounters[address]--;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span class="selflink" style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Ok, that's end of the &lt;a href="http://blogs.msdn.com/b/dboyle/archive/2013/02/12/technical-interview-screen-questions.aspx"&gt;coding tests series&lt;/a&gt; for now. These were fun(ish) to write and also pretty quick to write (so they've really upped my posting frequency recently). But I do have an overdue requested update&amp;nbsp;to add to my &lt;a href="http://apps.microsoft.com/windows/app/irish-tides/7d36b364-0523-4bcf-8c32-97d3f445f731"&gt;Windows 8 app&lt;/a&gt;, and have another app idea to work on, so I need to divert my spare time&amp;nbsp;in that direction again now.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10401157" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /><category term="Queues" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Queues/" /></entry><entry><title>Linked list stuff in a modern environment</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/11/linked-list-stuff-in-a-modern-environment.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/11/linked-list-stuff-in-a-modern-environment.aspx</id><published>2013-03-11T11:18:00Z</published><updated>2013-03-11T11:18:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So recently somebody asked about this and seemed surprised when I said that owing to the&amp;nbsp;availability of lots of lists and collection classes in modern frameworks,&amp;nbsp;I had not coded a linked list in&amp;nbsp;a couple of decades, at least not&amp;nbsp;since&amp;nbsp;I completed my BSc (finished in 1996 while employed by IBM). So anyways, I decided to include them in this blog series just to show&amp;nbsp;I can do it if I have to!&amp;nbsp;I suppose it still makes sense to think about collection class implementation every now and then&amp;nbsp;- it may be&amp;nbsp;very useful&amp;nbsp;in some future role if performance tweaking on structures like these becomes important. One caveat is that I have just included these quickly, and so haven't really optimised or thought about the "best" way to do the following methods - just made ones that work (without much testing).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;For these examples I have used a Single Linked List. This class defines it and the following method is used just to display the list contents of the list:&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; class SLLNode&lt;br /&gt; {&lt;br /&gt; public int value;&lt;br /&gt; &lt;br /&gt; public SLLNode pNext;&lt;br /&gt; &lt;br /&gt; public SLLNode(int val)&lt;br /&gt; {&lt;br /&gt; value = val;&lt;br /&gt; pNext = null;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; private static void DisplayLL(SLLNode current)&lt;br /&gt; {&lt;br /&gt; while (current != null)&lt;br /&gt; {&lt;br /&gt; Console.WriteLine("Node value {0}", current.value);&lt;br /&gt; current = current.pNext;&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Copying a Single Linked List&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Can be little confusing as you're effectively stepping through two lists, the existing list and the one you are creating as you go:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; private static SLLNode CopySLL(SLLNode n1)&lt;br /&gt; {&lt;br /&gt; SLLNode current = n1;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; SLLNode newHead = new SLLNode(n1.value);&lt;br /&gt; SLLNode prev = newHead;&lt;br /&gt; &lt;br /&gt; while (current != null)&lt;br /&gt; {&lt;br /&gt; current = current.pNext; //old list&lt;br /&gt; &lt;br /&gt; if (current != null)&lt;br /&gt; {&lt;br /&gt; SLLNode newNode = new SLLNode(current.value);&lt;br /&gt; prev.pNext = newNode;&lt;br /&gt; prev = prev.pNext;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; DisplayLL(newHead);&lt;br /&gt; return newHead;&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Sorting a Single Linked List&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;J&lt;/span&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;ust using a&amp;nbsp;simple bubble sort here for a list with integer values in the payload. I'm writing this on a tired Sunday evening, so feel free to suggest "improvements"!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; private static void SortSLL(SLLNode head)&lt;br /&gt; {&lt;br /&gt; SLLNode current;&lt;br /&gt; int swaps = 1;&lt;br /&gt; &lt;br /&gt; while (swaps &amp;gt; 0)&lt;br /&gt; {&lt;br /&gt; current = head;&lt;br /&gt; swaps = 0;&lt;br /&gt; while (current != null)&lt;br /&gt; {&lt;br /&gt; SLLNode next = current.pNext;&lt;br /&gt; &lt;br /&gt; if (next != null)&lt;br /&gt; {&lt;br /&gt; if (current.value &amp;gt; next.value)&lt;br /&gt; {&lt;br /&gt; int tmp = current.value;&lt;br /&gt; current.value = next.value;&lt;br /&gt; next.value = tmp;&lt;br /&gt; swaps++;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; current = next; //move along&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Reverse a Single Linked List&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Walk the list, reversing the "pNext" pointers as you go - just need to remember not to orphan any nodes, and to set the original head's "next" pointer to point to null as it becomes the tail&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; private static SLLNode ReverseSLL(SLLNode head)&lt;br /&gt; {&lt;br /&gt; SLLNode current = head;&lt;br /&gt; &lt;br /&gt; SLLNode prev;&lt;br /&gt; &lt;br /&gt; SLLNode next = current.pNext; &lt;br /&gt; &lt;br /&gt; while (next != null)&lt;br /&gt; {&lt;br /&gt; prev = current;&lt;br /&gt; current = next;&lt;br /&gt; next = current.pNext;&lt;br /&gt; current.pNext = prev;&lt;br /&gt; }&lt;br /&gt; head.pNext = null;&lt;br /&gt; &lt;br /&gt; return current;&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10401128" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /><category term="Linked Lists" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Linked+Lists/" /></entry><entry><title>Checking for a prime number</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/08/checking-for-a-prime-number.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/08/checking-for-a-prime-number.aspx</id><published>2013-03-08T16:16:07Z</published><updated>2013-03-08T16:16:07Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Ok, looking back at the original &lt;a href="http://blogs.msdn.com/b/dboyle/archive/2013/02/12/technical-interview-screen-questions.aspx"&gt;post&lt;/a&gt;&amp;nbsp;I'm nearly regretting it as I need to find the time to actually write these - but at least this one was quick and simple. In fact it may be too simple to use as a tech test, but anyways here it is.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;A prime number is any number greater than 1 which is&amp;nbsp;only divisible by itself and 1. The method I use here simply checks all the values up to the number under investigation to see if division by them would leave a remainder of zero. There are probably faster ways to do this using smarter maths, and if you know of one, please post a comment!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399;"&gt;&lt;code class="cplusplus"&gt; private static bool IsPrime(int num)&lt;br /&gt; {&lt;br /&gt; if (num &amp;lt;= 1)&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; for (int i = 2; i &amp;lt; num; i++)&lt;br /&gt; {&lt;br /&gt; if (num % i == 0)&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; return true;&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400695" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /><category term="Prime Numbers" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Prime+Numbers/" /></entry><entry><title>Checking if a string is a palindrome</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/08/checking-if-a-string-is-a-palindrome.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/08/checking-if-a-string-is-a-palindrome.aspx</id><published>2013-03-08T15:52:00Z</published><updated>2013-03-08T15:52:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Back in my original college days (over 20 years ago now) this used to be the subject of a running joke. It seemed that&amp;nbsp;with every new language learned one of the first exercises was to check for palindromes, and the joke was that we couldn't wait to get into gainful employment with some large corporation, hopefully working with their Palindrome product group - as we had so much experience!. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So what's a palindrome? &lt;a href="http://en.wikipedia.org/wiki/Palindrome"&gt;Wikipedia&lt;/a&gt;&amp;nbsp;explains it as "a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction". So we're basically checking if the string can be reversed and still have the same letter order.&amp;nbsp;In&amp;nbsp;.Net&amp;nbsp;we could use String.Reverse() and work on the resulting list, but doing it the old fashioned way I get code like this&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; char[] checkChars = testString.ToCharArray();&lt;br /&gt; &lt;br /&gt; for (int i = 0; i &amp;lt; checkChars.Length / 2; i++)&lt;br /&gt; {&lt;br /&gt; if (checkChars[i] != checkChars[checkChars.Length - i - 1])&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; return true;&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;But that method would fail on some common palindromic strings like "Navan" (casing) or "A man a plan a canal panama" (casing and spaces).&amp;nbsp;So in the full version&amp;nbsp;I ignore casing and spaces to get an implementation like:&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; private static bool IsPalindrome(string testString)&lt;br /&gt; {&lt;br /&gt; StringBuilder checkChars = new StringBuilder();&lt;br /&gt; &lt;br /&gt; foreach (char c in testString.ToLower())&lt;br /&gt; {&lt;br /&gt; if (c != ' ')&lt;br /&gt; {&lt;br /&gt; checkChars.Append(c);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; for (int i = 0; i &amp;lt; checkChars.Length / 2; i++)&lt;br /&gt; {&lt;br /&gt; if (checkChars[i] != checkChars[checkChars.Length - i - 1])&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; return true;&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400686" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /><category term="Palindrome" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Palindrome/" /></entry><entry><title>Quicksort</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/06/quicksort.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/06/quicksort.aspx</id><published>2013-03-06T22:36:00Z</published><updated>2013-03-06T22:36:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Along with Mergesort, Bubblesort and others, Quicksorting of arrays is a standard on any fully fledged undergraduate computer science course. It&amp;rsquo;s a simple theory, and like a lot of theories can be easily described verbally, on a whiteboard or even in pseudocode, but they all take a little work to actually implement. Quicksort is&amp;nbsp;a "divide and conquer&amp;rdquo; comparison sorting algorithm. The basic idea is that you continually reduce the area of the array under inspection (or unsorted area) by arranging the values around a pivot value (which can be chosen randomly), and then doing the same to the left and right sub arrays in a recursive fashion. Acually Wikipedia explain this much better so here is their &lt;a href="http://en.wikipedia.org/wiki/Quicksort"&gt;link&lt;/a&gt;. They also have a nice pseudocode version, repeated here:&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; function quicksort('array')&lt;br /&gt; if length('array') &amp;le; 1&lt;br /&gt; return 'array' // an array of zero or one elements is already sorted&lt;br /&gt; select and remove a pivot value 'pivot' from 'array'&lt;br /&gt; create empty lists 'less' and 'greater'&lt;br /&gt; for each 'x' in 'array'&lt;br /&gt; if 'x' &amp;le; 'pivot' then append 'x' to 'less'&lt;br /&gt; else append 'x' to 'greater'&lt;br /&gt; return concatenate(quicksort('less'), 'pivot', quicksort('greater')) // two recursive calls&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;It is common (and makes the explanation easy) to refer to dividing the array into left and right sub arrays or lists. In .Net you certainly could use lists, but it is&amp;nbsp;much more efficient to use the same array, moving values and passing indices to inform each recursion of their sub portion of the array. In my implementation I use a class called Quicksorter, and calling QuickSort() on an instance of this class will trigger a call to the recursive method qsort passing the initial 0 and Length-1 parameters.&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #333399; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; class QuickSorter&lt;br /&gt; {&lt;br /&gt; int[] intArray;&lt;br /&gt; &lt;br /&gt; public QuickSorter(int[] unsorted)&lt;br /&gt; {&lt;br /&gt; intArray = new int[unsorted.Length];&lt;br /&gt; unsorted.CopyTo(intArray, 0);&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void PrintArray()&lt;br /&gt; {&lt;br /&gt; for (int i = 0; i &amp;lt; intArray.Length - 1; i++)&lt;br /&gt; {&lt;br /&gt; Console.Write(intArray[i] + ", ");&lt;br /&gt; }&lt;br /&gt; Console.WriteLine(intArray[intArray.Length - 1]);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void QuickSort()&lt;br /&gt; {&lt;br /&gt; qsort(0, intArray.Length - 1);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; private void qsort(int left, int right)&lt;br /&gt; {&lt;br /&gt; int pivot, lft, rgt;&lt;br /&gt; &lt;br /&gt; lft = left;&lt;br /&gt; rgt = right;&lt;br /&gt; pivot = intArray[left];&lt;br /&gt; &lt;br /&gt; while (left &amp;lt; right)&lt;br /&gt; {&lt;br /&gt; while ((intArray[right] &amp;gt;= pivot) &amp;amp;&amp;amp; (left &amp;lt; right))&lt;br /&gt; {&lt;br /&gt; right--;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (left != right)&lt;br /&gt; {&lt;br /&gt; //now we know the rhs value is less than the pivot, so move it (left was saved as the pivot value)&lt;br /&gt; //and move the lhs counter after the operation&lt;br /&gt; intArray[left++] = intArray[right];&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; while ((intArray[left] &amp;lt;= pivot) &amp;amp;&amp;amp; (left &amp;lt; right))&lt;br /&gt; {&lt;br /&gt; left++;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (left != right)&lt;br /&gt; {&lt;br /&gt; //now we know the lhs value is greater than the pivot, so move it, rhs is pointing to a value which has been copied/duped to the lhs, basically a free space&lt;br /&gt; //and move the rhs counter after the operation&lt;br /&gt; intArray[right--] = intArray[left];&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //pivot value can slot back in to the free/duplicate lhs space&lt;br /&gt; intArray[left] = pivot;&lt;br /&gt; &lt;br /&gt; //reset lhs, rhs and pivot&lt;br /&gt; pivot = left;&lt;br /&gt; left = lft;&lt;br /&gt; right = rgt;&lt;br /&gt; &lt;br /&gt; if (left &amp;lt; pivot)&lt;br /&gt; {&lt;br /&gt; qsort(left, pivot - 1);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (right &amp;gt; pivot)&lt;br /&gt; {&lt;br /&gt; qsort(pivot + 1, right);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;This class could easily be adapted for other value types and could easily be altered to sort arrays of any object by:&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;a)&amp;nbsp;Implementing the &lt;a href="http://msdn.microsoft.com/en-us/library/system.collections.icomparer.aspx"&gt;IComparer&lt;/a&gt;&amp;nbsp;interface&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;b) Changing the comparison lines to use the results of .Compare(object1, object2)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400055" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /><category term="Sorting" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Sorting/" /></entry><entry><title>Greatest Common Divisor (and Lowest Common Multiple)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/03/04/greatest-common-divisor-and-lowest-common-multiple.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/03/04/greatest-common-divisor-and-lowest-common-multiple.aspx</id><published>2013-03-04T11:06:00Z</published><updated>2013-03-04T11:06:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;It's worth repeating the wikipedia definition for GCD here, as it's explains it well: "The greatest common divisor (gcd), also known as the greatest common factor (gcf), or highest common factor (hcf), of two or more non-zero integers, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4. (See their full explanation &lt;a href="http://en.wikipedia.org/wiki/Greatest_common_divisor"&gt;here&lt;/a&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Euclid's algorithm to derive the GCD is simple and fast, and easily implemented in code as:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #000080; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; static int GetGCD(int num1, int num2)&lt;br /&gt; {&lt;br /&gt; //check for valid inputs&lt;br /&gt; if (num1 &amp;lt; 1 || num2 &amp;lt; 1)&lt;br /&gt; {&lt;br /&gt; return -1;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; while (num1 != num2)&lt;br /&gt; {&lt;br /&gt; if (num1 &amp;gt; num2)&lt;br /&gt; {&lt;br /&gt; num1 = num1 - num2;&lt;br /&gt; }&lt;br /&gt; if (num2 &amp;gt; num1)&lt;br /&gt; {&lt;br /&gt; num2 = num2 - num1;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; return num1;&lt;/code&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;In this approach the greater&amp;nbsp;number decreases by the difference each time until they equal each other (at which point there woult also be no remainder from a modulus operation between them). This lower, equal number is the GCD. In some implementations you might see an "else" clause between the two "if" statements, but leaving it out as is done here allows for two reduction operations to happen between loop tests. You can do the same by applying the modulus operand to the two numbers swapping the results each time as you re-enter the loop.&amp;nbsp;&amp;nbsp;It's all about getting the remainder to equal&amp;nbsp;0. &lt;/span&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;We can do this with&amp;nbsp;recursion as seen here:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #000080; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; public static int RecursiveGCD(int num1, int num2)&lt;br /&gt; {&lt;br /&gt; if (num2 == 0)&lt;br /&gt; {&lt;br /&gt; return num1;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return RecursiveGCD(num2, num1 % num2);&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;This second example has no handling for zero values, and while it won't crash it will give results for zeroes or minus numbers. One way of bullet-proofing this would be to have two methods - one which performs the valid inputs check, and then just calls the recursive method.&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;&amp;nbsp;Lowest (or least) common multiple&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Again using&amp;nbsp;the Wikipidea definition: "The least common multiple (also called the lowest common multiple or smallest common multiple) of two integers a and b, usually denoted by LCM(a, b), is the smallest positive integer that is divisible by both a and b.[1] If either a or b is 0, LCM(a, b) is defined to be zero.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So I can't remember if this was also a Euclides formula, but dividing the product of the two numbers by their greatest common divisor gives the smallest possible common product of these two numbers individually multiplied with another, as follows:&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #000080; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; static int GetLCM(int num1, int num2)&lt;br /&gt; {&lt;br /&gt; return (num1 * num2) / GetGCD(num1, num2);&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10399046" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /></entry><entry><title>Binary Search Tree</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/02/22/binary-search-tree.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/02/22/binary-search-tree.aspx</id><published>2013-02-22T17:36:00Z</published><updated>2013-02-22T17:36:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;This is a simple data structure, but again one with which many of us may have not been familiar with in some time. But it seems to beloved of tech screeners (and very useful in networking software) so a refresher is always nice; I have here put together a simple sorted tree and some equally simple methods, both recursive and non-recursive for the main operations, which are:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Insertion&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Finding nodes in the tree&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Displaying the tree&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I created a class imaginatively called "BinarySearchTree" to implement this. In retrospect this constrcted my recursion to require helper methods, as I needed to pass the root node into the helper which was then treated as the "current" node and passed to future recursions. Not a big overhead, but a tad annoying. Here is the code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;First class is the TreeNode class, a simple class which assigns the identifier value upon construction.&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #000080; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; class TreeNode&lt;br /&gt; {&lt;br /&gt; public int nodeValue{get;set;}&lt;br /&gt; public TreeNode leftBranch, rightBranch;&lt;br /&gt; &lt;br /&gt; public TreeNode(int value)&lt;br /&gt; {&lt;br /&gt; nodeValue=value;&lt;br /&gt; leftBranch=null;&lt;br /&gt; rightBranch=null;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Then the BinarySearchTree class with Insert,&amp;nbsp;Find and Display methods. This Display method does not show the nodes in order of value. Will make one of those next.&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #000080; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; class BinarySearchTree&lt;br /&gt; {&lt;br /&gt; TreeNode root = null;&lt;br /&gt; &lt;br /&gt; public BinarySearchTree(TreeNode rootNode)&lt;br /&gt; {&lt;br /&gt; root = rootNode;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public TreeNode Find(int keyValue)&lt;br /&gt; {&lt;br /&gt; TreeNode currentNode = root;&lt;br /&gt; &lt;br /&gt; while (currentNode != null)&lt;br /&gt; {&lt;br /&gt; if (currentNode.nodeValue == keyValue)&lt;br /&gt; {&lt;br /&gt; return currentNode;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; if (keyValue &amp;lt; currentNode.nodeValue)&lt;br /&gt; {&lt;br /&gt; currentNode = currentNode.leftBranch;&lt;br /&gt; }&lt;br /&gt; if (keyValue &amp;gt; currentNode.nodeValue)&lt;br /&gt; {&lt;br /&gt; currentNode = currentNode.rightBranch;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; return null;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public TreeNode FindRecursive(int keyValue)&lt;br /&gt; {&lt;br /&gt; return findRecursiveHelper(root, keyValue);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; private TreeNode findRecursiveHelper(TreeNode current, int keyValue)&lt;br /&gt; {&lt;br /&gt; if (current == null)&lt;br /&gt; {&lt;br /&gt; return null;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (current.nodeValue == keyValue)&lt;br /&gt; {&lt;br /&gt; return current;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (keyValue &amp;lt; current.nodeValue)&lt;br /&gt; {&lt;br /&gt; if (current.leftBranch != null)&lt;br /&gt; {&lt;br /&gt; return (findRecursiveHelper(current.leftBranch, keyValue));&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return null;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (keyValue &amp;gt; current.nodeValue)&lt;br /&gt; {&lt;br /&gt; if (current.rightBranch != null)&lt;br /&gt; {&lt;br /&gt; return (findRecursiveHelper(current.rightBranch, keyValue));&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return null;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; return null;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; public void Insert(TreeNode newNode)&lt;br /&gt; {&lt;br /&gt; InsertHelper(root, newNode);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; private void InsertHelper(TreeNode current, TreeNode newNode)&lt;br /&gt; {&lt;br /&gt; if (newNode.nodeValue &amp;lt; current.nodeValue)&lt;br /&gt; {&lt;br /&gt; if (current.leftBranch == null)&lt;br /&gt; {&lt;br /&gt; current.leftBranch = newNode;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; InsertHelper(current.leftBranch, newNode);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; if (newNode.nodeValue &amp;gt; current.nodeValue)&lt;br /&gt; {&lt;br /&gt; if (current.rightBranch == null)&lt;br /&gt; {&lt;br /&gt; current.rightBranch = newNode;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; InsertHelper(current.rightBranch, newNode);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void DisplayTree()&lt;br /&gt; {&lt;br /&gt; displayTreeHelper(root);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; private void displayTreeHelper(TreeNode current)&lt;br /&gt; {&lt;br /&gt; Console.WriteLine(current.nodeValue.ToString());&lt;br /&gt; &lt;br /&gt; if (current.rightBranch != null)&lt;br /&gt; {&lt;br /&gt; displayTreeHelper(current.rightBranch);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (current.leftBranch != null)&lt;br /&gt; {&lt;br /&gt; displayTreeHelper(current.leftBranch);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;To use the classes then I can call them from Main() as follows:&lt;/span&gt;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #000080; font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; BinarySearchTree bst = new BinarySearchTree(root);&lt;br /&gt; bst.Insert(new TreeNode(25));&lt;br /&gt; bst.Insert(new TreeNode(45));&lt;br /&gt; bst.Insert(new TreeNode(75));&lt;br /&gt; bst.Insert(new TreeNode(85));&lt;br /&gt; bst.Insert(new TreeNode(95));&lt;br /&gt; bst.Insert(new TreeNode(15));&lt;br /&gt; bst.Insert(new TreeNode(27));&lt;br /&gt; TreeNode tn = bst.Find(85);&lt;br /&gt; TreeNode trn = bst.FindRecursive(27);&lt;br /&gt; bst.DisplayTree();&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;As in the other articles the next things I need to ponder is, "If a candidate delivers this answer, what questions do we ask next?" Some potentials are:&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Rewrite the Display method to display the nodes in order of values (in-order Traversal)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;What optimisations can be applied to these trees?&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;If using the tree to store data, then manipulation of&amp;nbsp;regularly searched-for data to be acessible the top of a tree makes sense - extra points here for any mention of&amp;nbsp;AVL, Red-black, treap etc...&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;and of course - what unit tests would you write&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;which can be applied to every method in the classes&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10396258" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author><category term="Coding tests" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Coding+tests/" /><category term="Interviews" scheme="http://blogs.msdn.com/b/dboyle/archive/tags/Interviews/" /></entry><entry><title>Checking a string for a valid ISBN number</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/dboyle/archive/2013/02/20/checking-a-string-for-a-valid-isbn-number.aspx" /><id>http://blogs.msdn.com/b/dboyle/archive/2013/02/20/checking-a-string-for-a-valid-isbn-number.aspx</id><published>2013-02-20T17:43:00Z</published><updated>2013-02-20T17:43:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Continuing the series of "things you may have done in college" this next one is all about array manipulation. Again it's one I've heard of being used in a whiteboard/tech interview situation (so worth brushing up on!). The scenario here is just the creation of a method which:&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Accepts a string&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Checks to see if that string is actually a valid&amp;nbsp;10 digit ISBN number format&amp;nbsp; (valid &lt;em&gt;format&lt;/em&gt; -&amp;nbsp;an actually valid ISBN no. is one which has been issued to a published book)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;The only other stipulation is to do it in the first instance without using the built-in .NET string methods. So it would be quicker to use String.Split('-') etc... but the idea here is to test the basic knowledge, so the first effort here uses just standard array walking loops. I may add a more modern implementation later, but as &amp;nbsp;previously stated I would love if these post generated some comments, and perhaps other implementation styles in those comments.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;I took the "business logic", i.e. the&amp;nbsp;10 digit ISBN rules from here: &lt;a href="http://www.isbn.org/standards/home/isbn/international/html/usm4.htm"&gt;http://www.isbn.org/standards/home/isbn/international/html/usm4.htm&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;This is the first hastily written version:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #003366; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; private static bool IsTenDigitISBN(string isbnString)&lt;br /&gt; {&lt;br /&gt; if (string.IsNullOrWhiteSpace(isbnString))&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; char[] isbnArray = isbnString.ToArray();&lt;br /&gt; &lt;br /&gt; if (isbnArray[0] == '-' || isbnArray[isbnArray.Length - 1] == '-')&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (isbnArray.Length != 10 &amp;amp;&amp;amp; isbnArray.Length != 13)&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; int dashCount = 0;&lt;br /&gt; int sum = 0;&lt;br /&gt; int digit=0;&lt;br /&gt; &lt;br /&gt; //now replace the '-' chars in pos 0-9&lt;br /&gt; for (int i = 0; i &amp;lt; isbnArray.Length-1; i++)&lt;br /&gt; {&lt;br /&gt; if (isbnArray[i] == '-')&lt;br /&gt; {&lt;br /&gt; dashCount++;&lt;br /&gt; isbnArray[i]=isbnArray[i--+1];&lt;br /&gt; for (int x = i + 1; x &amp;lt; isbnArray.Length-1; x++)&lt;br /&gt; {&lt;br /&gt; isbnArray[x] = isbnArray[x + 1];&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; if (dashCount != 0 &amp;amp;&amp;amp; dashCount != 3)&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //if array is 13 long, we must have 3 dashes, 10 long must have no dashes&lt;br /&gt; if ((isbnArray.Length == 13 &amp;amp;&amp;amp; dashCount !=3) &amp;amp;&amp;amp; (isbnArray.Length == 10 &amp;amp;&amp;amp; dashCount !=0))&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; for (int i=0; i &amp;lt; 9; i++)&lt;br /&gt; {&lt;br /&gt; if (ToDigit(isbnArray[i], ref digit))&lt;br /&gt; {&lt;br /&gt; int multiplier = 10 - i;&lt;br /&gt; int val=digit*multiplier;&lt;br /&gt; sum += val;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //now add the check digit (or 10 if it is an 'X' character)&lt;br /&gt; if (isbnArray[9] == 'X' || isbnArray[9] == 'x')&lt;br /&gt; {&lt;br /&gt; sum += 10;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; if (ToDigit(isbnArray[9], ref digit))&lt;br /&gt; {&lt;br /&gt; sum += digit;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //Sum of digits + check digit should have a remainder of 0 when divided by 11&lt;br /&gt; int check = sum % 11;&lt;br /&gt; &lt;br /&gt; if (check == 0)&lt;br /&gt; {&lt;br /&gt; return true;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return false;&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;As you can see there is one other small method called within the check method - the ToDigit() method which converts a char to an int (if the char is one of '0' - '9'). It is shown here:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="scroll"&gt;&lt;span style="color: #003366; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; /// &amp;lt;summary&amp;gt;&lt;br /&gt; /// An "atoi()" style function for single characters&lt;br /&gt; /// &amp;lt;/summary&amp;gt;&lt;br /&gt; /// &amp;lt;param name="ch"&amp;gt;character which should represent a digit&amp;lt;/param&amp;gt;&lt;br /&gt; /// &amp;lt;param name="digit"&amp;gt;pass by ref int used to return the value&amp;lt;/param&amp;gt;&lt;br /&gt; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt; private static bool ToDigit(char ch, ref int digit)&lt;br /&gt; {&lt;br /&gt; char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;span style="color: #003366; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; bool found=false;&lt;br /&gt; &lt;br /&gt; for (int i = 0; i &amp;lt; digits.Length; i++)&lt;br /&gt; {&lt;br /&gt; if (ch==digits[i])&lt;br /&gt; {&lt;br /&gt; digit=i;&lt;br /&gt; found=true;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (found)&lt;br /&gt; {&lt;br /&gt; return true;&lt;br /&gt; }&lt;/code&gt;&lt;code class="cplusplus"&gt;&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;span style="font-family: terminal,monaco; font-size: medium;"&gt;&lt;code class="cplusplus"&gt; &lt;br /&gt;&lt;span style="color: #003366;"&gt; return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #003366;"&gt; }&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;So that's it - comments welcome. Questions which could be asked around this include the standard&amp;nbsp;"which unit tests would you write". Here's some examples of strings to pass:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Valid - return true:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;IsTenDigitISBN("90-70002-34-5"));&lt;br /&gt;IsTenDigitISBN("0-8436-1072-7"));&lt;br /&gt;IsTenDigitISBN("1590593006"));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Invalid - return false:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;IsTenDigitISBN("-"));&lt;br /&gt;IsTenDigitISBN("--1234556789--"));&lt;br /&gt;IsTenDigitISBN("123-45-567-8-9"));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;Other questions to ask then would be perhaps:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;How to improve it/rewrite it using .NET string methods.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: medium;"&gt;How to check for a 13 digit ISBN also - in the same method?&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10395638" width="1" height="1"&gt;</content><author><name>DermotB</name><uri>http://blogs.msdn.com/dermotb_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry></feed>