anup.h.nair
BAN USERSummary
• Application Developer, Database Architect in a wide variety of web portals and business applications.
Specialties
• High performance Web application development using Microsoft and LAMP Technologies.
• Scrum development model for project management.
• Information Systems Development, Deployment and Consulting.
• Verticals: Health Insurance, News/Media/Publishing, Stock Exchange, Electronic Marketing and CRM (Retention and Support).
- » My Blog
Skills & Expertise
Microsoft: .net 4/4.5, C#, ASP.NET, MVC (with Razor), WCF, WPF, SQL Server, IIS, TFS.
Web Technologies: JavaScript (with Libraries), DOM, jQuery, JSON, AJAX, HTML 5 CSS 3
High performance Web: Reduced HTTP Requests, CSS Sprites, GZip, CDN, JavaScript development pattern, W3C & ECMA standards Compliance.
Project Management: Scrum
Also Familiar with: PHP, MySQL Linux, C++, Joomla, Dolibarr, Apache, SEO principles.
Work Experience:
Senior Software Engineer at iGATE Global Solutions
iGATE Corporation [NASDAQ listed (IGTE)] is a $1.2 Billion (2011) IT services company.
February 2011 – Present, Mumbai, India
Senior Software Engineer at Bombay Stock Exchange Limited (Marketplace Technologies)
September 2010 - February 2011, Mumbai, India
Web Developer at Xisto Corporation
June 2008 - September 2010, Mumbai, India
Education
SIES College of Management Studies / University of Mumbai
• Masters in Computer Applications (MCA)
• Activities and Societies: Won at inter college events.
SIES - College of Science, Arts & Commerce / University of Mumbai
• Bachelor of Science, Information Technology(IT)
• Activities and Societies: Won at inter college events.
Languages
English (Native or bilingual proficiency)
Hindi (Native or bilingual proficiency)
Japanese (Professional working proficiency)
Interests
New technology, cross-cultural studies, and history.
//Recursive is better
public int minDepth(Node root)
{
if (root == null) { return 0; }
return 1 + Math.Min(minDepth(root.leftNode), minDepth(root.rightNode));
}
//C#
using System;
using System.Collections;
class Node
{
public int value;
public Node leftNode;
public Node rightNode;
public Node(int _value)
{
value = _value;
}
}
class BinarySearchTree
{
Node rootNode;
Queue[] printQueue;
public BinarySearchTree(int _value)
{
rootNode = new Node(_value);
}
public void add(int _value)
{
addRec(rootNode, _value);
printQueue = new Queue[maxDepth(rootNode)];
for (int i = 0; i < maxDepth(rootNode); i++)
{
printQueue[i] = new Queue();
}
}
public void addRec(Node _node, int _value)
{
if (_node == null) return;
if (_value < _node.value)
{
addRec(_node.leftNode, _value);
if (_node.leftNode == null)
{ _node.leftNode = new Node(_value); }
}
else if (_value >= _node.value)
{
addRec(_node.rightNode, _value);
if (_node.rightNode == null)
{
_node.rightNode = new Node(_value);
}
}
}
public void print()
{
printQueue[0].Enqueue(rootNode.value);
BreadthFirst(rootNode, 1);
for (int i = 0; i < printQueue.Length; i++)
{
while (printQueue[i].Count != 0)
{
Console.Write(printQueue[i].Dequeue());
}
Console.WriteLine();
}
}
public void BreadthFirst(Node _node, int _level)
{
if (_node == null) { return; }
if (_node.leftNode != null)
{
printQueue[_level].Enqueue(_node.leftNode.value);
}
if (_node.rightNode != null)
{
printQueue[_level].Enqueue(_node.rightNode.value);
}
++_level;
BreadthFirst(_node.leftNode, _level);
BreadthFirst(_node.rightNode, _level);
}
public int maxDepth(Node root)
{
if (root == null) { return 0; }
return 1 + Math.Max(maxDepth(root.leftNode), maxDepth(root.rightNode));
}
}
class Program
{
static void Main(string[] args)
{
BinarySearchTree myTree = new BinarySearchTree(6);
myTree.add(4);
myTree.add(5);
myTree.add(8);
myTree.add(2);
myTree.add(9);
myTree.add(11);
myTree.add(10);
myTree.print();
Console.Read();
}
}
//C#
using System;
using System.Collections;
class Node
{
public int value;
public Node leftNode;
public Node rightNode;
public Node(int _value)
{
value = _value;
}
}
class BinarySearchTree
{
Node rootNode;
Queue[] printQueue;
public BinarySearchTree(int _value)
{
rootNode = new Node(_value);
}
public void add(int _value)
{
addRec(rootNode, _value);
printQueue = new Queue[maxDepth(rootNode)];
for (int i = 0; i < maxDepth(rootNode); i++)
{
printQueue[i] = new Queue();
}
}
public void addRec(Node _node, int _value)
{
if (_node == null) return;
if (_value < _node.value)
{
addRec(_node.leftNode, _value);
if (_node.leftNode == null)
{ _node.leftNode = new Node(_value); }
}
else if (_value >= _node.value)
{
addRec(_node.rightNode, _value);
if (_node.rightNode == null)
{
_node.rightNode = new Node(_value);
}
}
}
public void print()
{
printQueue[0].Enqueue(rootNode.value);
BreadthFirst(rootNode, 1);
for (int i = 0; i < printQueue.Length; i++)
{
while (printQueue[i].Count != 0)
{
Console.Write(printQueue[i].Dequeue());
}
Console.WriteLine();
}
}
public void BreadthFirst(Node _node, int _level)
{
if (_node == null) { return; }
if (_node.leftNode != null)
{
printQueue[_level].Enqueue(_node.leftNode.value);
}
if (_node.rightNode != null)
{
printQueue[_level].Enqueue(_node.rightNode.value);
}
++_level;
BreadthFirst(_node.leftNode, _level);
BreadthFirst(_node.rightNode, _level);
}
public int maxDepth(Node root)
{
if (root == null) { return 0; }
return 1 + Math.Max(maxDepth(root.leftNode), maxDepth(root.rightNode));
}
}
class Program
{
static void Main(string[] args)
{
BinarySearchTree myTree = new BinarySearchTree(6);
myTree.add(4);
myTree.add(5);
myTree.add(8);
myTree.add(2);
myTree.add(9);
myTree.add(11);
myTree.add(10);
myTree.print();
Console.Read();
}
}
public int maxDepth(Node root)
{
if (root == null) { return 0; }
return 1 + Math.Max(maxDepth(root.leftNode), maxDepth(root.rightNode));
}
Was it accepted ?
- anup.h.nair December 31, 2012//C#
public int minDepth(Node root)
{
if (root == null) { return 0; }
return 1 + Math.Min(minDepth(root.leftNode), minDepth(root.rightNode));
}
//C# : It Works
using System;
class Balance
{
public int weightLeft;
public int weightRight;
public Balance leftBalance;
public Balance rightBalance;
public int totalWeight;
public Balance()
{
totalWeight = 10;
weightLeft = 0;
weightRight = 0;
}
public void addWeightLeft(int _value)
{
weightLeft = _value;
totalWeight = totalWeight + weightLeft;
}
public void addWeightRight(int _value)
{
weightRight = _value;
totalWeight = totalWeight + weightRight;
}
public void addLeftBalance(Balance _balance)
{
leftBalance = _balance;
weightLeft += _balance.totalWeight;
totalWeight += _balance.totalWeight;
}
public void addRightBalance(Balance _balance)
{
rightBalance = _balance;
weightRight += _balance.totalWeight;
totalWeight += _balance.totalWeight;
}
public void addLeftBalanceExtra()
{
if (leftBalance != null)
{
weightLeft += leftBalance.weightLeft;
weightRight += leftBalance.weightRight;
}
}
public void addRightBalanceExtra()
{
if (rightBalance != null)
{
weightLeft += rightBalance.weightLeft;
weightRight += rightBalance.weightRight;
}
}
}
class Program
{
static void Main(string[] args)
{
int N = Convert.ToInt32(Console.ReadLine());
Balance[] balance = new Balance[N];
for (int i = 0; i < N; i++)
{
balance[i] = new Balance();
}
for (int i = 0; i < N; i++)
{
string Line1 = Console.ReadLine();
string Line2 = Console.ReadLine();
string[] parts1 = Line1.Split(' ');
string[] parts2 = Line2.Split(' ');
balance[i].addWeightLeft(Convert.ToInt32(parts1[0]));
if (parts1.Length > 1)
{
for (int j = 1; j < parts1.Length; j++)
{
balance[i].addLeftBalance(balance[Convert.ToInt32(parts1[j])]);
}
}
balance[i].addWeightRight(Convert.ToInt32(parts2[0]));
if (parts2.Length > 1)
{
for (int j = 1; j < parts2.Length; j++)
{
balance[i].addRightBalance(balance[Convert.ToInt32(parts2[j])]);
}
}
}
for (int i = 0; i < N; i++)
{
balance[i].addLeftBalanceExtra();
balance[i].addRightBalanceExtra();
}
for (int i = 0; i < N; i++)
{
balance[i].addLeftBalanceExtra();
balance[i].addRightBalanceExtra();
}
for (int i = 0; i < N; i++)
{
if (balance[i].weightLeft < balance[i].weightRight)
{
Console.WriteLine(i + " : " + (balance[i].weightRight - balance[i].weightLeft) + " 0 ");
}
if (balance[i].weightLeft > balance[i].weightRight)
{
Console.WriteLine(i + " : 0 " + (balance[i].weightLeft - balance[i].weightRight));
}
if (balance[i].weightLeft == balance[i].weightRight)
{
Console.WriteLine(i + " : 0 0");
}
}
Console.Read();
}
}
class Node
{
public int value;
public Node nextNode;
public Node(int _value)
{
value = _value;
}
}
class stack
{
Node topNode; Node maxNode;
public int count = 0;
public stack(int _value)
{
topNode = new Node(_value);
maxNode = topNode;
++count;
}
public void push(int _value)
{
Node newNode = new Node(_value);
if(!(maxNode.value < _value))
{
maxNode = topNode;
newNode.nextNode = topNode;
topNode = newNode;
}
else
{
newNode.nextNode = topNode;
topNode = newNode;
}
++count;
}
public Node maxNode()
{
return maxNode;
}
public int pop()
{
int retval = topNode.value;
topNode = topNode.nextNode;
--count;
return retval;
}
public void sort()
{
Node currentNode = topNode;
while (currentNode != null)
{
Node runnerNode = currentNode.nextNode;
while (runnerNode != null)
{
if (currentNode.value > runnerNode.value)
{
int temp = currentNode.value;
currentNode.value = runnerNode.value;
runnerNode.value = temp;
}
runnerNode = runnerNode.nextNode;
}
currentNode = currentNode.nextNode;
}
}
public void print()
{
Console.WriteLine("Values of the node are");
Node currentNode = topNode;
while (currentNode != null)
{
Console.WriteLine(currentNode.value);
currentNode = currentNode.nextNode;
}
}
}
Given that this is a BST, it will have left and right pointer with the addition of parent pointer.
- anup.h.nair December 31, 2012//1) traverse from source node to the root node(top/first node) of BST.
At each traversal add the value of each node in a stack (say stack 1)
//2) traverse from the root node(top/first node) of BST to the destination node using InOrder .At each traversal add the value of each node in a stack (say stack 2)
//3) Compare stack1 with stack 2.
//3.1)if a node other than root node is common on both stack, then the path from source to destination will pass through that node skipping the root node. Print the values of stack 1 followed by stack 2.
//3.2)if there is no node other than root node is common on both stack, then the path from source to destination will pass through that root node. Print the values of stack 1 followed by stack 2.
//c#
public void path(Node _node)
{
if (_node == rootNode) { return; }
Stack1.push(_node.value);
path(Node _node.parentNode);
}
public void SearchRecord(Node _node, int _value)
{
if (_node == null) return 0;
if (_value < _node.value)
{
Stack2.push(_node.value);
SearchRecord(_node.leftNode, _value);
}
else if (_value > _node.value)
{
Stack2.push(_node.value);
SearchRecord(_node.rightNode, _value);
}
else if (_value == _node.value)
{
Stack2.push(_node.value);
return;
}
return;
}
public bool compare(Node _stack1Node,Node _stack2Node)
{
bool IsRepeated = false;
while(_stack1Node!= null)
{
while(_stack2Node != null_
{
if(_stack1Node.value == stack2Node.value)
{
IsRepeated = true;
}
}
_stack1Node=_stack1Node.nextNode;
}
return IsRepeated ;
}
//C#
static void display(int[,] _arr)
{
int[] smallestOfColumn = new int[_arr.GetLength(1)];
int[] smallestOfColumni = new int[_arr.GetLength(1)];
int[] smallestOfColumnj = new int[_arr.GetLength(1)];
for (int i = 0; i < _arr.GetLength(0); i++)
{
int biggestOfRow = _arr[i, 0];
int biggestOfRowi = i;
int biggestOfRowj = 0;
for (int j = 0; j < _arr.GetLength(1); j++)
{
if (biggestOfRow < _arr[i, j])
{
biggestOfRow = _arr[i, j];
biggestOfRowi = i;
biggestOfRowj = j;
}
if (i == 0)
{
smallestOfColumn[j] = _arr[i, j];
smallestOfColumni[j] = i;
smallestOfColumnj[j] = j;
}
if (smallestOfColumn[j] > _arr[i, j])
{
smallestOfColumn[j] = _arr[i, j];
smallestOfColumni[j] = i;
smallestOfColumnj[j] = j;
}
}
Console.WriteLine("Biggest of row " + (i + 1) + " is " + biggestOfRow + " at row " + (biggestOfRowi + 1) + " and column " + (biggestOfRowj + 1));
}
for (int j = 0; j < _arr.GetLength(1); j++)
{
Console.WriteLine("Smallest of column " + (j + 1) + " is " + smallestOfColumn[j] + " at row " + (smallestOfColumni[j] + 1) + " and column " + (smallestOfColumnj[j] + 1));
}
}
//c#
public Node nthToLast(int n)
{
Node runnerNode1 = firstNode;
Node runnerNode2 = firstNode;
for (int j = 0; j < n - 1; ++j)
{
runnerNode2 = runnerNode2.nextNode;
}
while (runnerNode2.nextNode != null)
{
runnerNode1 = runnerNode1.nextNode;
runnerNode2 = runnerNode2.nextNode;
}
return runnerNode1;
}
//C#
using System;
public class Node
{
public int value;
public Node nextNode;
public Node(int _value)
{
value = _value;
}
}
public class linkedlist
{
Node firstNode;
public linkedlist(int _value)
{
firstNode = new Node(_value);
}
public void add(int _value)
{
Node currentNode = firstNode;
while (currentNode.nextNode != null)
{
currentNode = currentNode.nextNode;
}
currentNode.nextNode = new Node(_value);
}
public void print()
{
Node printnode = firstNode;
while (printnode != null)
{
Console.WriteLine(" Value of Node is " + printnode.value);
printnode = printnode.nextNode;
}
}
public void removeDuplicates()
{
Node currentNode = firstNode;
while (currentNode != null)
{
Node runnerNode = currentNode;
Node previousRunnerNode = currentNode;
while (runnerNode != null)
{
if (currentNode.value == runnerNode.value)
{
previousRunnerNode.nextNode = runnerNode.nextNode;
runnerNode = runnerNode.nextNode;
}
else
{
previousRunnerNode = runnerNode;
runnerNode = runnerNode.nextNode;
}
}
currentNode = currentNode.nextNode;
}
}
}
class Program
{
static void Main(string[] args)
{
linkedlist MyLL = new linkedlist(0);
MyLL.add(10);
MyLL.add(8);
MyLL.add(8);
MyLL.add(4);
MyLL.add(8);
MyLL.add(6);
MyLL.print();
MyLL.removeDuplicates();
Console.WriteLine("After Removing duplicates");
MyLL.print();
Console.Read();
}
}
//C#
static char[] ReplaceWithString(char[] _str)
{
int whiteSpaceCount = 0;
for (int i = 0; i < _str.Length; i++)
{
if (_str[i] == ' ')
{
whiteSpaceCount += 1;
}
}
char[] replacedString = new char[_str.Length + ((whiteSpaceCount * 3) - whiteSpaceCount)];
for (int i = 0,j =0; i < replacedString.Length; i++)
{
if (!(_str[j] == ' '))
{
replacedString[i] = _str[j];
}
else
{
replacedString[i] = '%';
replacedString[++i] = '2';
replacedString[++i] = '0';
}
j++;
}
return (replacedString);
}
//C#
static void setZeros(int[,] _arr, int _iMax, int _jMax)
{
int[] rows = new int[_arr.GetLength(0)];
int[] colums = new int[_arr.GetLength(1)];
for (int i = 0; i < _iMax; i++)
{
for (int j = 0; j < _jMax; j++)
{
if (_arr[i, j] == 0)
{
rows[i] = 1;
colums[j] = 1;
}
}
}
for (int i = 0; i < _iMax; i++)
{
for (int j = 0; j < _jMax; j++)
{
if ((rows[i] == 1 || colums[j] == 1))
{
_arr[i, j] = 0;
}
}
}
}
//C#
static bool checkIf2StringsAreAnagrams(string _str1, string _str2)
{
bool isAnagrams = false;
Dictionary<char, int> charset = new Dictionary<char, int>();
for (int i = 0; i < _str1.Length; i++)
{
char key = _str1[i];
if (!charset.ContainsKey(key))
{
charset.Add(key, 1);
}
else
{
charset[key] += 1;
}
}
Dictionary<char, int> charset2 = new Dictionary<char, int>();
for (int i = 0; i < _str2.Length; i++)
{
char key = _str2[i];
if (!charset2.ContainsKey(key))
{
charset2.Add(key, 1);
}
else
{
charset2[key] += 1;
}
}
for (int i = 0; i < charset.Count; i++)
{
char key = charset.Keys.ElementAt(i);
if (charset2.ContainsKey(key))
{
if (charset[key] == charset2[key])
{
isAnagrams = true;
}
else
{
isAnagrams = false; break;
}
}
else
{
isAnagrams = false; break;
}
}
return (isAnagrams);
}
//C#
static bool checkIf2StringsAreAnagrams(string _str1, string _str2)
{
bool isAnagrams = false;
Dictionary<char, int> charset = new Dictionary<char, int>();
for (int i = 0; i < _str1.Length; i++)
{
char key = _str1[i];
if (!charset.ContainsKey(key))
{
charset.Add(key, 1);
}
else
{
charset[key] += 1;
}
}
Dictionary<char, int> charset2 = new Dictionary<char, int>();
for (int i = 0; i < _str2.Length; i++)
{
char key = _str2[i];
if (!charset2.ContainsKey(key))
{
charset2.Add(key, 1);
}
else
{
charset2[key] += 1;
}
}
for (int i = 0; i < charset.Count; i++)
{
char key = charset.Keys.ElementAt(i);
if (charset2.ContainsKey(key))
{
if (charset[key] == charset2[key])
{
isAnagrams = true;
}
else
{
isAnagrams = false; break;
}
}
else
{
isAnagrams = false; break;
}
}
return (isAnagrams);
}
//C#
//O(n)
static char[] removeDuplicateChars(char[] _str)
{
bool[] charset = new bool[256];
for (int i = 0; i < _str.Length; i++)
{
int val = _str[i];
if (charset[val]) { _str[i] = ' '; }
charset[val] = true;
}
return _str;
}
//c# O(n)
static char[] removeDuplicateChars(char[] _str)
{
for (int i = 0; i < _str.Length; i++)
{
for (int j = i+1; j < _str.Length; j++)
{
if (_str[i] == _str[j])
{
_str[j] = ' ';
}
}
}
return _str;
}
//c# O(n)
static char[] removeDuplicateChars(char[] _str)
{
bool[] charset = new bool[256];
for (int i = 0; i < _str.Length; i++)
{
int val = _str[i];
if (charset[val]) { _str[i] = ' '; }
charset[val] = true;
}
return _str;
}
Regular expression
- anup.h.nair December 16, 2012//C# implmentation
static int MaxCharacterRepeatation(string _str)
{
int Max = 1;
Dictionary<int,int> charset = new Dictionary<int, int>();
for (int i = 0; i <_str.Length; i++)
{
int val = _str[i];
if (!charset.ContainsKey(val))
{
charset.Add(val, 1);
}
else
{
charset[val] = charset[val]+1;
if (charset[val] > Max)
{
Max = charset[val];
}
}
}
return (Max);
}
}
- anup.h.nair December 16, 2012
I think people are mistaken about one thing. "We are not given the pointer to the destination node." Hence from the source node we have to traverse till the destination node.
- anup.h.nair January 01, 2013In my point of view the one possible way we can do this is the method I specified in my comment.