Tuesday, March 7, 2017

Algorithms: What's the difference between an Algorithm and Psuedo-code?

This blog is based off of a question from one of my subscribers, Debojit Acharjee:
“Hi! I want to know how to write an algorithm and is there any syntax for writing algorithm? What is the difference between algorithm and pseudocode?”
Debojit, in order to understand the clear difference, how to write algorithms, and whether or not we have the syntax available to write those algorithms, we need to understand these terms first. If you look up “algorithm” in the Oxford dictionary, you will find the definition “a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer”.
This definition does not bind you to use a particular syntax when writing an algorithm. But, it does mention some phrases, like “rules to be followed”, “calculations”, “problem-solving operations”, and “especially by a computer”, which can’t be imagined without some formal discipline. Therefore, you don’t have to follow a specific strict grammar (syntax) to write an algorithm, per se, as long as you are able to communicate “the process” or “the set of rules” to do a particular task or solve a problem, and of course, doing it in a finite number of steps, optimally.
Next, let’s say you want to write an algorithm to arrange three distinct random numbers in ascending order. You can do so in plain English, using block diagrams, pseudocode, or you could create a flowchart. “Algorithm” is a term used mostly in Mathematics and Computing. Therefore, you write algorithms to communicate with other people in fields like Mathematics and Computing. You wouldn’t write an algorithm for preparing a cup of tea for your breakfast, but you would certainly write an algorithm to sort 10 random numbers in ascending or descending order.
“Algorithm” is a formal term. One example of an algorithm you could write is to find the biggest of three distinct integers, and here’s an example:
Example of a flowchart showing an algorithm to find the biggest of 3 distinct integers.

Let’s get back to the Oxford dictionary again: it defines
pseudo-code as “a notation resembling a simplified programming language, used in program design”.
Analyzing this word, you see it consists of two separate words, “pseudo”, and “code”. Let’s break this down:
The word “pseudo” loosely means “false”, or “not actual”. When read with the second word, it’s “pseudo-code”, which should lead you to its meaning - which is false (close to) code. Pseudo-code is the English-y representation of code, but it’s not actual code. It’s written as if you are actually writing code, but the programming language and hardware specifics have been taken away from it for two main reasons:
  1. Universally Understandable. One of the main goals of pseudo-code is to be understandable by all coders - universally.
  2. Universally Translatable. Once all coders are able to understand the pseudo-code, just like someone who knows 2 different languages and is able to translate between them, the coders can then implement the solutions that the pseudo-code is providing in their choice of programming language.
Pseudo-code to display the biggest of the three distinct integers would look like:
var: n1, n2, n3, BiggestInt
READ n1, n2, n3
BiggestInt = n1
IF BiggestInt < n2
   BiggestInt = n2
IF BiggestInt < n3
   BiggestInt = n3
DISPLAY “The biggest integer is:”, BiggestInt
I hope this helps, Debojit!

Thursday, November 19, 2015


Hello there and welcome to my first blog post, in a new series, highlighting the amazing power of the Supercomputer: Watson!

First of all, what is Watson?

Watson, simply put, is an intelligent, NLQA (Natural Language Question Answering) system developed by IBM. It has the capability to answer questions posed to it in natural language. Watson has enough cognitive ability to learn about any topic, with a "corpus" of knowledge fed into Watson by humans. Such corpora include Healthcare, Travel and Cooking - its current 3 main uses. Watson is also continuously trained by professionals in the area that he is trying to learn.

Examples of an NLQA system could be Siri, Google Now, Sirius, or Cortana to name of a few.

However,  Google, Bing, Yahoo, DuckDuckGo don't fall into this category.

The difference is that NLQA systems actually extract the answers and give them to the user. However, search engines just give back results that may hold the answers, and humans have to dig into the results and find the answers themselves. Also, if you, in general, don't know what "Natural Language" is, it's what we're using right now, to talk and to communicate.

Also, in the past, Watson had an extremely difficult test, to see if it actually has the power to be the most advanced NLQA system out there.

Watson played a game of "Jeopardy!", a game show where contestants are shown clues, and they have to come up with questions as answers. Watson played against the game show's two best contestants: "Ken Jennings" and "Brad Rutter" (imagine ANY other NLQA system even trying to do that).
To everyones surprise, Watson won that game with $1,000,000.

Watson's big win actually meant and indicated that it should be put to an appropriate use elsewhere and therefore IBM decided to put it to use in Healthcare, Travel and Cooking at the moment.

You might want to know: The project manager for Watson is "David Ferrucci"
You might also want to know: Watson was built on IBM's "POWER7" Supercomputer.

Watson also has the capability to "learn", using algorithms classified under "Machine Learning". Now, what this allows Watson to do, is to make sure that it never repeats a mistake. I will take an example here. Young kids have an urge to draw on the wall. When they do it, parents usually scold them. Over time the kids link drawing on the wall with a negative outcome of their actions. Their brains don’t want the negative outcome, so they learn not to draw on the wall . Similarly Watson links mistakes with a negative outcome so, it'll learn not to make mistakes. 

Furthermore, Watson works by using these four steps, to determine the answer to a question:

1. Question Analysis - In this step, Watson will try to figure out what the question is asking for, and what the answer type (should) be.

2. Hypothesis Generation - Here, Watson creates hundreds of different possible candidate answers. These are mostly answers that are wrong by a LOT, but again, it NEEDS a lot of answers to choose from. Because later, Watson will have an extreme variety of answers to choose from, and will probably score the correct answer as correct.

3. Hypothesis and Evidence Scoring - Now, Watson will try to weigh each answer. It will downgrade wrong answers, by looking at the evidence that does NOT support the hypothesis, and upgrade correct answers, with evidence that DOES support the hypothesis.

4. Final Merging and Ranking - Finally, Watson ranks all the candidate answers, and displays the top 3 answers on the answer panel. It gives confidence scores for each candidate answer and says out the final, first ranked answer, in hopes that it is right.

This blog post was an introduction to the IBM Watson NLQA system.

I will continue to write and take you into depth on how to use Watson, and also release a few articles on how to use Watson APIs as well.

My due credits and thanks to IBMWatson.com

Monday, July 20, 2015


Welcome to a VERY simple blog post, also my first tutorial!

This time, I will be teaching you how to use something called an "NSTimer".

These are the very useful applications of the NSTimer:

- Repeating a block of code over and over
- Checking for updates from a web server
- Creating a timer
- Checking variables, repeatedly
- Executing a block of code after a time delay


Let's see how to create a function for the Timer (just a simple Swift function, that will print "Hello World"):

func printHelloWorld() {
    print("Hello World")

Next, let's see how we can start the timer:

var timer = NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: "printHelloWorld", userInfo: nil, repeats: true)

The above timer will call the "printHelloWorld" function every 2 seconds.

You can also create a timer, without starting it:

var timer = NSTimer(timeInterval: 2, target: self, selector: "printHelloWorld", userInfo: nil, repeats: true)

The above timer will take all variables into account, but to start it, you must add it to Swift's "Run Loop":

NSRunLoop.currentRunLoop().addTimer(timer, forMode: NSRunLoopCommonModes)
That will start the loop.
No matter what method you choose of starting the timer, you always end it like so:

That's it for this simple tutorial! If you have any more questions or suggestions, please email me at: tajymany@gmail.com

Hope you learned something new and enjoyed it!

Tuesday, July 7, 2015

XCodeToIPA (Part 2) FAQ

Welcome to the FAQ for the "XCodeToIPA (Part 2)" video that I released. Whenever someone asks me a question about this video and I am able to get a working answer for them, I will also be uploading the question and answer here. Here they are:

Q: Can I remove the popup that says "dl.dropboxusercontent would like to install <appname>" after I click on "Install"?
A: Sorry, no you cannot! If you could, it would be a system vulnerability. This is due to the fact that the install button is ACTUALLY a link, and if you were to be automatically redirected to a link like that, someone could install a malicious app right onto your iDevice! If the popup stays, however, then you can just "Deny" the app from being put onto your device. So, Apple decided to keep the popup there with force.

Thursday, July 2, 2015

First Post!

Welcome to my Blog. This is my first post, explaining what I will be writing & sharing in this blog!

1) I will be putting up written, article versions of some of my short videos (on iOS, Mac, and Swift)
2) Basic & Advanced Swift tutorials
3) Information about technology, that were not fit for a video
4) I will even make some posts on how to create games in Swift!

Hope you enjoy!

You can mail me at: tajymany@gmail.com