[algogeeks] Re: use putchar to print out an unsigned long in decimal

2009-10-15 Thread Siddharth S
void putlong(long n) { if(n == 0) // special case { putchar('0'); return; } else if(n 0) // if number is negative, print - sign and continue as if it is a positive number putchar('-'), n = -n; int arr[30]; int arr_cnt = 0; while(n) { arr[arr_cnt++]

[algogeeks] Re: Finding repeated element in most efficient way

2009-08-09 Thread Siddharth S
assuming the numbers are n-bit numbers, 1. have an array, arr, of n elements, initialize all elements with 0. 2. traverse the input array 3. if input[i] is a power of 2, arr[ lg(input[i]) ] ++; // where lg is logarithm to the base 2. 4. after traversing input array, see if any element in

[algogeeks] Re: Algo Question

2009-07-01 Thread Siddharth S
The problem seems to be minimum dominating set problem (which is NP-complete i think). But since the number of nodes will be =26, it can be solved by some intelligent brute force. Something like this might work: Take all subsets of the given nodes. Iteratively keep increasing the size of the

[algogeeks] Re: STL map uses Hashing?

2008-05-29 Thread Siddharth S
I thk it uses balanced trees (like Red Black Trees). Not sure though On Thu, May 29, 2008 at 12:16 PM, Vinodh [EMAIL PROTECTED] wrote: I am reading about hashing techniques. The map data structure available in C++ STL uses hashing techniques?