Saturday, August 20, 2011

Ah, the joys of poor messages, brief documentation and faded memories!

Today, I was at Hack Dev days in Vancouver, B.C. and enjoyed the group and the presentations. Two recent Uni-grads and I teamed up and proceeded to define a project and work away for most of the day.  We were using the TinEye.com API, specifically a collection of 10 million images from Flickr that they have in one of their libraries. We decided to create a Chrome Extension on the API (one of the other dev’s had done one of these recently).

 

It’s been 16 months since I have done any serious JavaScript/Ajax stuff, and that was (in hind-sight) unfortunately against the website where the pages were hosted…

 

The code that consumed most of the day…

The code below should have been up and working in 15 minutes…

    <script type="text/javascript">
        var ApiUrl = 'http://piximilar-rw.hackdays.tineye.com/rest/'
        function myData() {
            var fd = new FormData();
            fd.append("method", "color_search");
            fd.append("colors[0]", "#FFFFFF");
            fd.append("colors[1]", "#F080C0");
            fd.append("weights[0]", "90");
            fd.append("weights[1]", "10");
            fd.append("color_format", "hex");
            fd.append("limit", "10");
            return fd;
        }
        var data = null;
        function testcall() {            
            var xhr = new XMLHttpRequest();
            xhr.open("POST", ApiUrl);
            xhr.onload = function () {
                data = JSON.parse(xhr.responseText);
            }
            xhr.onerror = function () { alert(xhr.status); }
            xhr.send(myData())
        }
    </script>

 

The problem was that the status was a zero(0) with no status message.  Googling XMLHttpRequest and zero status code found many pages describing a similar issue but no clear explanation (or solution).  I installed the latest version of Fiddler Web Debugger, and saw that the call went off fine, and that the service returned the appropriate JSON fine.

 

image

So the call to the API was being correctly done, results were coming back but with a bizarre status code of zero. Asking around the local HACK developers and no one had an answer….  So it was off trying to find a solution, including trying $.ajax () – which provided less information, overriding mime types, changing “POST” to various other REST verbs (GET was rejected by the API)… the typical systematic trying every variation that came to mind. My colleagues were also encountering problems that they could not identify the cause ….

 

Looking at TinEye.com API documentation did not help, it was centric around the use of cURL with no examples that could be easily copied. They supplied some sample pages using FORMS, but our intent was calling if from JavaScript, so it was not particularly helpful…

 

Well, finally the light went on (I was the one that realize the issue), we were trying to do cross domain POSTs. It turned out that their obtuse problems were the same issue.

 

In hind-sight, the waste of time could have been avoided if:

  • There was a statusText message that went with the zero status code (i.e. “Security violation – cross domain post”), or
  • The .send() raised an error message….
    • Seeing the data coming back in Fiddler, lead me down the wrong path – the API appear to be working correctly…
  • The TinEye.com documentation had reminded the reader about the cross-domain posting issue
    • Ideally, the documentation would have sample code on how to create the needed component on your own server in all of the common languages. Having the code ready to cut-and-paste would have improved adoption
    • Personally, I would love to see firms providing API’s contract out to a seasoned technical developer engineer (what I use to be called at Microsoft) who is good at:
      • Technical writing
      • Creating non-trivial engineering code examples that goes the “extra mile” (resulting in faster adoption of the API).
      • Anticipating how novice developers are likely to proceed and making them successful!
      • The Facebook API is THE classic example of how not to do API documentation.
  • I (or my fellow hacks) had bumped up against the cross-domain API post issues recently.

That’s it for today’s RANT…

Wednesday, August 17, 2011

Windows Azure Service Dashboard OPML Feed File

In case you don’t want to add all the RSS feeds on the Windows Azure Service Dashboard, I’ve created an OPML file you can import into your (Google) reader. The file is up on Windows Live Skydrive but in case you can’t get to that, the file contents are below. If you found I’m missing a link or the link has changed, please let me know.

 

<?xml-stylesheet type="text/xsl" href="http://www.microsoft.com/feeds/msdn_opmlpretty.xsl" version="1.0"?>
<opml version="1.1">
  <head>
    <title>Azure Service Dashboard Feeds</title>
  </head>
  <body>
    <outline text="AppFabric Access Control [East Asia]" title="AppFabric Access Control [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSACSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control [North Central US]" title="AppFabric Access Control [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSACSNCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control [North Europe]" title="AppFabric Access Control [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSACSNE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control [South Central US]" title="AppFabric Access Control [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSACSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control [Southeast Asia]" title="AppFabric Access Control [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSACSSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control [West Europe]" title="AppFabric Access Control [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSACSWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control 2.0 [East Asia]" title="AppFabric Access Control 2.0 [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=ACS2EA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control 2.0 [North Central US]" title="AppFabric Access Control 2.0 [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=ACS2NCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control 2.0 [North Europe]" title="AppFabric Access Control 2.0 [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=ACS2NE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control 2.0 [South Central US]" title="AppFabric Access Control 2.0 [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=ACS2SCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control 2.0 [Southeast Asia]" title="AppFabric Access Control 2.0 [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=ACS2SEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Access Control 2.0 [West Europe]" title="AppFabric Access Control 2.0 [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=ACS2WE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Caching [East Asia]" title="AppFabric Caching [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=AFCEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Caching [North Central US]" title="AppFabric Caching [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=AFCNCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Caching [North Europe]" title="AppFabric Caching [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=AFCNE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Caching [South Central US]" title="AppFabric Caching [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=AFCSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Caching [Southeast Asia]" title="AppFabric Caching [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=AFCSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Caching [West Europe]" title="AppFabric Caching [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=AFCWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Portal [Worldwide]" title="AppFabric Portal [Worldwide]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSPortWW" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Service Bus [East Asia]" title="AppFabric Service Bus [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSSBEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Service Bus [North Central US]" title="AppFabric Service Bus [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSSBSNCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Service Bus [North Europe]" title="AppFabric Service Bus [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSSBSNE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Service Bus [South Central US]" title="AppFabric Service Bus [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSSBSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Service Bus [Southeast Asia]" title="AppFabric Service Bus [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSSBSSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="AppFabric Service Bus [West Europe]" title="AppFabric Service Bus [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=NSSBWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Database Manager [East Asia]" title="Database Manager [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DBMEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Database Manager [North Central US]" title="Database Manager [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DBMNCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Database Manager [North Europe]" title="Database Manager [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DBMNE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Database Manager [South Central US]" title="Database Manager [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DBMSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Database Manager [Southeast Asia]" title="Database Manager [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DBMSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Database Manager [West Europe]" title="Database Manager [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DBMWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Database [East Asia]" title="SQL Azure Database [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SAEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Database [North Central US]" title="SQL Azure Database [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SANCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Database [North Europe]" title="SQL Azure Database [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SANE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Database [South Central US]" title="SQL Azure Database [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SASCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Database [Southeast Asia]" title="SQL Azure Database [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SASEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Database [West Europe]" title="SQL Azure Database [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SAWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="SQL Azure Reporting [South Central US]" title="SQL Azure Reporting [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=SARSSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure CDN [Worldwide]" title="Windows Azure CDN [Worldwide]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACDNWW" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Compute [East Asia]" title="Windows Azure Compute [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Compute [North Central US]" title="Windows Azure Compute [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACNCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Compute [North Europe]" title="Windows Azure Compute [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACNE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Compute [South Central US]" title="Windows Azure Compute [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Compute [Southeast Asia]" title="Windows Azure Compute [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Compute [West Europe]" title="Windows Azure Compute [West Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WACWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Connect [Worldwide]" title="Windows Azure Connect [Worldwide]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WAConnectWW" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Marketplace - DataMarket [South Central US]" title="Windows Azure Marketplace - DataMarket [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=DMSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Service Management [Worldwide]" title="Windows Azure Service Management [Worldwide]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASvcMgmtWW" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Storage [East Asia]" title="Windows Azure Storage [East Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Storage [North Central US]" title="Windows Azure Storage [North Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASNCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Storage [North Europe]" title="Windows Azure Storage [North Europe]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASNE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Storage [South Central US]" title="Windows Azure Storage [South Central US]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASSCUS" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Storage [Southeast Asia]" title="Windows Azure Storage [Southeast Asia]" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASSEA" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
    <outline text="Windows Azure Storage [Southeast Asia]" title="" type="rss" xmlUrl="http://www.microsoft.com/windowsazure/support/status/RSSFeed.aspx?RSSFeedCode=WASWE" htmlUrl="http://www.microsoft.com/windowsazure/support/status/servicedashboard.aspx"/>
  </body>
</opml>
<?xml version="1.0" encoding="utf-8"?>

Monday, August 1, 2011

Tech Qu: The checking your degree questions…

University transcripts are no longer trusted because of grade inflation and even bogus degrees. The result is that often people are asked questions that anyone that has taken a 3rd year computer science course (recently) should be able to answer. Personally, I feel these questions are biased for recent graduates and against those that have been in the industry many years. They are theory centric and not practical center.

 

On Glassdoor, one contributor says it perfectly:

There are many question which will from you university course of Informatics, so worth to renew that knowledge. Many puzzles, and mostly of them you can find in internet. Nothing difficult, just good exam on things which you will never use in real life.

 

A few examples are:

Differences between Array, Linked List, Heap etc

You could dive into mechanisms of implementation, or cite a table (i.e. rote learning) such as

 

Linked list

Array

Dynamic array

Balanced tree

Indexing

Θ(n)

Θ(1)

Θ(1)

Θ(log n)

Insert/delete at beginning

Θ(1)

N/A

Θ(n)

Θ(log n)

Insert/delete at end

Θ(1)

N/A

Θ(1) amortized

Θ(log n)

Insert/delete in middle

search time +
Θ(1)[1]

N/A

Θ(n)

Θ(log n)

Wasted space (average)

Θ(n)

0

Θ(n)

Θ(n)

 

And for Heaps

Operation

Binary

Binomial

Fibonacci

Pairing[2]

Brodal[3]

findMin

Θ(1)

Θ(log n) or Θ(1)

Θ(1)[1]

O(1)*

Θ(1)

deleteMin

Θ(log n)

Θ(log n)

O(log n)*

O(log n)*

O(log n)

insert

Θ(log n)

O(log n)

Θ(1)[citation needed]

O(1)*

Θ(1)

decreaseKey

Θ(log n)

Θ(log n)

Θ(1)*

O(log n)*

Θ(1)

merge

Θ(n)

O(log n)**

Θ(1)

O(0)*

Θ(1)

Linked List:

  • Elements added without reorganizing data items
  • Finding items means that you must walk the nodes from the head (or tail)

What is Big O and name some sorting algorithms and their performance…

Excuse me, there is rarely a need to ever write a sort in practice unless you are writing languages! In general, those facilities are provided by the language. If you have a photographic memory, just go to Wikipedia’s page on sorting algorithms.

Binary Search Algorithm and Big O for it

For us old timers, we called this approach Newtonian. It’s doing a divide the sorted range in half, check the value and then repeat on which ever interval that the desired value is in.

Data structure Array

Worst case performance        O(log n)

Best case performance           O(1)

Average case performance   O(log n)

Worst case space complexity O(1)

 

Breadth First Search on a binary tree

Again, another question that is testing rote learning (i.e. if you can answer it by referencing a page on Wikipedia – the question really should not be used. You are testing rote ability, if the job requires creative solutions – you have blown it.

Write a method to traverse a Binary Tree

See page on Wikipedia.

 

Describe Semaphores and Deadlocks

Again,  Semaphone and Deadlock are Wiki-questions.

The better solution

Look at issues that you are trying to solve, or solved recently. Recast them as open ended questions and see what the candidate can do with it. If the candidate solves an open question – you know he will be a net positive component to the group, if he comes up with a better solution to a closed question, he clearly is as good or better than existing staff. If he comes up with equivalent to solutions to a closed question, he’s likely the same grade as the current staff.

 

Rhetorical questions and Rote questions are poor performance indicators compared to the above.