## Extension of .NET Framework to Provide Language Integrated Query (LINQ) !

Hello !

At PDC 2005 Microsoft has announced Language Integrated Query Project in voice of Anders Heljsberg (Distinguish Engineer and Chief Architect C#) to elaviate the difference between programming approach of accessing data between SQL Programming Languages and High level languages. For details dont forget to read a Q&A session at

http://www.microsoft.com/presspass/features/2005/sep05/09-13NETLanguage.mspx

Regards.

Haroon

## The 80xxxxxx series error and Exception Certificate !

Hello !

Yesternight , i was fixing my cousin's pc when i came around a problem, msn messenger was not able to connect to .NET passport. I tried some old tricks and everytime i got the terrible 80xxxxx series error. Although the DNS was able to resolve the IP. So i got around a trick .I created a by pass certificate for the msn service being hosted by WOL (ISP server in my case), and added it to the Modem's advanced security services. Some how the problme was resolved. If you have Windows XP with service pack > 1, the firewall is by default on and you may have to perform all these efforts so be watchful…

Regards,

Haroon

## Towers of Powers – Perfect Base Program!

Hello !

One of the many problems in computer-generated graphics is realistically modeling the "orderly randomness" of things like mountain ranges and city skylines. Using fluctuations in number representations to model height can be used in such case. So in this case we compute several such number representations and show the "skylines" they produce.

Let n be any positive integer, and let b be an integer greater than or equal to 2. The complete base-b expansion of n is obtained as follows. First write the usual base-b expansion of n, which is just a sum of powers of b, each multiplied by a coefficient between 1 and b-1, omitting terms with zero coefficients. For example, if n = 20000 and b = 3, the base-3 expansion of 20000 is given by

20000 = 3^9 + 3^5 + 2*3^3 + 2

To obtain the complete base-b expansion, we apply the same procedure to the exponents until all numbers are represented in base b. For n = 20000 and b = 3 we would have

20000 = 3^3^2 + 3^(3+2) + 2*3^3 + 2*3^3 + 2

This is a real challenging problem to solve . I solved it once in an In-House competition and once in a Nation wide programming competition. Here is the C++ source code of solution

void perfectBase(unsigned long, unsigned long);

unsigned long calculateMultiple(unsigned long, unsigned long, unsigned long);

void function(unsigned long, const char *);

char * str , * ptr;

main(){

unsigned long number = 200000 , base = 64789;

str = new char[500] , ptr = new char[50];

strcpy(ptr,"") , strcpy(str,"");

//ofstream O("d:\\perfbase.txt");

textmode(C80), textcolor(WHITE), clrscr();

perfectBase(number,base);

puts(str);

//O 1)

function( multiple, "*");

if(power >= base){

function( base,"^");

if( power>base)

function( -1,"(");

perfectBase( power,base);

if( power>base)

function( -1,")");

}

else{

if( power==1)

function( base,"");

else{

if( power==0)

function( 1,"");

else{

function( base,"^");

function( power,"");

}

}

}

if(remNumber>=base){

function(-1,"+");

perfectBase(remNumber,base);

}

else

if(remNumber > 0 && remNumber

## Generating Subsets !

Hello !

Finding subsets of a set is one of the most difficult deterministic time problem. Specially finding an iterative solution for this problem is even more hard. Fortunately I once worked on combinatoric problems and solved this problem. I wrote the following C++ code to print the subsets of single element set in form of a string. (I will explain the algorithm some other time as I am running short of time…)

main()

{

char **subsetString, setString[100]="", temp[100] = "", tempString[100] = "";

int diff = 0 , subsetRows = 0, subsetColumns = 0;

cout

## Iterative In-Order Tree Traversal !

Hello !

All the DS Techies would be familiar with the famous In-Order tree traversal. However most of the algorithms for traversals are recursive. Once my friend was asked to write an In-Order tree traversal without recursion. I was also asked the same question and I wrote the following algorithm.

InOrder_TreeTraversal()

{

prev = null;

current = root;

next = null;

while( current != null )

{

if(prev == current.parent)

{

prev = current;

next = current.left;

}

if(next == null || prev == current.left)

{

print current.value;

prev = current;

next = cuurent.right;

}

if(next == null || prev == current.right)

{

prev = current;

next = cuurent.parent;

}

current = next;

}

}

The idea is to use another link which is a link to the parent node. So the above code do the same.

Regards,

Haroon Saeed

## Printing an Array in Spiral Order !

Hello !

Once I had to write a code to print an N*N array in spiral order. Well it was a really thinkable process to get to the solution and this problem was also asked in Microsoft interviews. So here I go with the C# code to print an array in spiral order,

public void PrintInSpiral(int [][] numbers, int size)

{

for(int i = size – 1 , j = 0 ; i >= 0 ; i–, j++)

{

for(int k = j ; k < i; k++)

Console.Write(numbers[j][k]+ " ");

for(int k = j ; k < i; k++)

Console.Write(numbers[k][i]+ " ");

for(int k = i ; k > j; k–)

Console.Write(numbers[i][k]+ " ");

for(int k = i ; k > j; k–)

Console.Write(numbers[k][j]+ " ");

}

}

if the array has a rank of 4 and contains elements as follows.

1 , 2 , 3 , 4

5 , 6 , 7 , 8

9, 10 , 11, 12

13, 14, 15, 16

then the output should be 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10. So run the above code and do dry run it on any N*N array ðŸ™‚

Regards,

Haroon