Monday, 22 October 2012

How wireless charging works


The fact that over 200,000 people have downloaded one of the various “shake to charge” apps, now available from Google Play, indicates our willingness to suspend any form of practical reasoning in pursuit of the dream of wireless charging. A quick investigation of the source code would likely reveal these apps do little more than to link the interrupt signal from the accelerometer to a progress bar indicating an alleged battery charge. A Piezoelectric accelerometer could generate a small voltage secondary to deformations induced by rapid motions applied to it, however trying to use that millivolt signal to charge a battery would not be practical. In order words, shaking your smartphone isn’t going to do anything but get your arm tired.

Sunday, 21 October 2012

Graphs


Graphs

  • Representation
    • Adjacency Matrix
    • Adjacency Lists
  • Traversal schemes
    • DFS (Depth First Search)
    • Breadth First Search (BFS)
  • Minimal Spanning
    • Kruskal
    • Prim

Queues



  • Queues
    • Introduction
    • Representation
    • Operations
    • Implementation
      • Simple queue
      • With front always at zero
      • Linked queue
      • Dequeue
      • Priority Queues
        • Max Priority
        • Min Priority

Queues

Recursion


Recursion

A function call is said to be recursive, if we invoke a function from within the same function.  The phenomenon being referred to as recursion.  A termination condition must be specified with each recursive call to avoid infinite execution of that function.  Recursion is basically required whenever a function has to operate upon different set of values to obtain the result.

Evaluation of Infix expression


Application of Stacks

Evaluation of Infix expression

An infix expression is evaluated using two stacks, one for operator and another for operands.  The infix sting is read in an array, from which symbols/characters are fetched one by one and the following checks are performed:

Conversion from Prefix to Infix


Application of Stacks

Conversion from Prefix to Infix

The algorithm for converting a Prefix expression to an Infix notation is as follows:
  • Accept a prefix string from the user.
  • Start scanning the string from right one character at a time.
  • If it is an operand, push it in stack.
  • If it is an operator, pop opnd1, opnd2 and concatenate them in the order (opnd1, optr, opnd2) as follows:

Conversion from Prefix to Postfix


Application of Stacks

Conversion from Prefix to Postfix

The algorithm for converting a Prefix expression to a Postfix notation is as follows:
  • Accept a prefix string from the user.
  • Start scanning the string from right one character at a time.
  • If it is an operand, push it in stack.
  • If it is an operator, pop opnd1, opnd2 and concatenate them in the order (opnd1, opnd2, optr) as follows:

Conversion from Postfix to Infix


Application of Stacks

Conversion from Postfix to Infix

The algorithm for converting a Postfix expression to Infix notation is as follows:
  •  Accept a postfix string from the user.
  • Start scanning the string from left to right one character at a time.
  • If it is an operand, push it in stack.
  • If it is an operator, pop opnd2, opnd1 and concatenate them in the order (opnd1, optr, opnd2) as follows:

Conversion from Postfix to Prefix


Application of Stacks

Conversion from Postfix to Prefix

The algorithm for converting a Postfix expression to Prefix notation is as follows:
  •  Accept a postfix string from the user.
  • Start scanning the string from left to right one character at a time.
  • If it is an operand, push it in stack.
  • If it is an operator, pop opnd2, opnd1 and concatenate them in the order (optr, opnd1, opnd2) as follows:

Conversion from Infix to Prefix


Application of Stacks

Conversion from Infix to Prefix

The algorithm for converting an Infix expression to Prefix is as follows:
An Infix expression is converted into Prefix using two stacks, one for operator and another for operands.  The infix sting is read in an array, from which symbols/characters are fetched one by one and the following checks are performed:

Conversion from Infix to Postfix


Application of Stacks

Conversion from Infix to Postfix

The algorithm for converting an Infix expression to Postfix is as follows:
An Infix expression is converted into Postfix using two stacks, one for operator and another for operands.  The infix sting is read in an array, from which symbols/characters are fetched one by one and the following checks are performed:

Saturday, 20 October 2012

Evaluation of Prefix expression


Application of Stacks

Evaluation of Prefix expression

The algorithm for evaluating a prefix expression is as follows:
  • Accept a prefix string from the user.
say (-*+ABCD), let A=4, B=3, C=2, D=5
i.e. (-*+4325) is the input prefix string.

Evaluation of Postfix expression


Application of Stacks

Evaluation of Postfix expression

The algorithm for evaluating a postfix expression is as follows:
  • Accept a postfix string from the user.
say (ABCD*+-), let A=4, B=3, C=2, D=5
i.e. (4325*+-) is the input postfix string.

Parenthesis checker


Application of Stacks

Parenthesis checker

It is an algorithm that confirms that the number of closing parenthesis equals opening parenthesis by using stack.  If number of closing parenthesis is not equal to the number of opening parenthesis, then it results in an error.  Input a string from the user.  The user must enter a set of opening and closing parenthesis as follows:

Polish Notations


Polish Notations

In the early 1920s, a Polish logician, Jan Lukasiewicz invented a special notation for prepositional logic that allows to eliminate all parenthesis from formulas.  The notation is called Polish Notation, which results in a less readable expression.  Depending upon the arrangement of operators and operands in an expression, Polish notation may be classified as:
  • Infix Polish Notation
  • Prefix Polish Notation
  • Postfix Polish Notation
Infix Polish Notation:  In this notation, the operator comes between two operands.  For example: A+B, where A, B are operands and + is an operator.
Prefix Polish Notation:  In this notation, the operator comes before two operands.  For example: +AB.
Postfix Polish Notation:  In this notation, the operator comes after two operands.  For example: AB+.
Application of Stacks:
  1. Parenthesis checker
  2. Evaluation of Postfix expression
  3. Evaluation of Prefix expression
  4. Evaluation of Infix expression
  5. Conversion from Infix to Postfix
  6. Conversion from Infix to Prefix
  7. Conversion from Postfix to Prefix
  8. Conversion from Postfix to Infix
  9. Conversion from Prefix to Postfix
  10. Conversion from Prefix to Infix

Program to implement Stack using Linked List


Stacks

Program to implement Stack using Linked List:

Trees


Trees

Definitions:

Binary Tree:  A binary tree is either empty or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root.

Threaded Binary Trees

Threaded Binary Trees

Threaded Binary Trees are an improvement over Binary Search Trees that uses stack for iterative traversal.  If a strategy is introduced such that the leaf node of a binary search tree points to its inorder predecessor or its successor, then direct links (called threads) are obtained to traverse a tree without using stack, which basically stores and retrieves the address of nodes in LIFO manner.  If the left pointer of the leaf node points to its inorder predecessor, then such a threaded tree is called Left-In-Threaded Binary Tree.  If the right pointer of the leaf node points to its inorder successor, then such a threaded tree is referred to as Right-In-Threaded Binary Tree. However, if both the links, left as well as right are available, then the threaded tree is called In-Threaded Binary Tree.

Program to implement Left-In- And Right-InThreaded Binary Tree


Left-In-Threaded Binary Tree

Program to implement Left-In-Threaded Binary Tree:

Program to implement various operations on a Binary Search Tree



Binary Search Tree:

Program to implement various operations on Binary Search Tree:

Binary Search Tree


Binary Search Tree

A Binary Search Tree is a Binary Tree which satisfies the following conditions:
  1. The left subtree of the root contains keys smaller than the root.
  2. The right subtree of the root contains keys greater than the root.
  3. The left and right subtrees are also Binary Search Trees.
  4. There are no duplicates in the tree.

Conversion of a Linked List into Array


Conversion of a Linked List into Array

The conversion process involves creation of a linked list.  Then the list is read from the first node till the last node such that each node value is stored in an array and the node is removed by freeing its memory.  The array is then displayed as an output.

Polynomial – Representation, Addition, Multiplication


Polynomial Manipulation

  • Representation
  • Addition
  • Multiplication

Circular Linked List


Circular Linked list

A circular linked list is similar to that of a singly linked list with the only difference that the last node points the first node of the list, such that a circular path is obtained.  Thus last node of this list instead of pointing to NULL points to the head node as described in the following figure:-

Doubly Linked List


Representation of a doubly linked list:
A doubly linked list contains backward as well as forward reference.  Each node contains two address along with the information field.  One address is the address of the next node and the other one is that of the previous node.  Thus doubly linked list is a bi-directional list, since we may traverse either from left to right or from right to left directly without any pointer manipulations as was the case with singly linked list.

Singly Linked List


Representation of  a Linked List: 
A singly linked list is one in which one node points to the next node and so on, where node contains an information part and an address to the next node of the same type.  The concept of linked list may be illustrated using the following figure:

Arrays-Programs




  • Linear Arrays
    • Memory representation/address calculation
    • Operations
      • Traversal
      • Search
        • Linear
        • Binary
      • Insertion
        • Insertion at a position
        • Sorted Insertion
      • Deletion
        • Deletion from a position
        • Sorted deletion

Introduction to Algorithm Design


1.  Introduction to Algorithms
  • Input, output, definiteness, finiteness, effectiveness.
  • Top-down & Bottom-up approaches
  • Algorithm complexity
    • Space complexity
    • Time complexity
    • Time space trade off
  • Big ‘O’ notation

Basic concepts of Data Representation


1.  Abstract and System defined data types
  • Data type
  • Primitive data type
  • Abstract data type
  • Polymorphic data type

Monday, 8 October 2012

Draft Background in Word

This trick shows you how to add a grey background text on your document. For example, when you have a draft document, and you want to make sure other people know it is a draft version. It is a good idea to have a background printed text, i.e. "DRAFT" on every page of your document. This feature is called "Watermark" in MS Word.
You can follow the same steps to create different watermarks. For example "SAMPLE", "DRAFT", "PERSONAL", or your own text.