Monthly Archives: October 2013

Turing Machine

A Turing machine (TM) is a tuple \(M=(Q, \Sigma, \delta)\) where \(Q\) is a finite set of states, containing a start state \(q_0\), an accepting state \(q_{y}\), and a rejecting state \(q_{n}\). The states \(q_{y}\) and \(q_{n}\) are distinct. \(\Sigma\)

Tagged with: , , ,
Posted in Theory

String StartsWith and EndsWith in JavaScript

The following are a simple implementation checking whether a string starts with a prefix or ends with a suffix in JavaScript. Here we use indexOf() method of JavaScript String object. Syntax: string.indexOf(search, start) Parameters: search is the string to search

Tagged with: , ,
Posted in JavaScript

Update Two Tables with Joins in MySQL

Here we show an example of updating two table at the same time using joins. Suppose we have two tables: lookup which holds information on a person, and activity which holds certain activities happening on a person. Imagine that lookup

Tagged with: ,
Posted in MySQL, SQL

Find Median of Two Sorted Arrays

The question is to find the median of two sorted arrays of numbers. Write an algorithm running in O(log n) time. The median of a list of numbers is the middle one when the list is sorted. When the list

Posted in Algorithm