Re: [algogeeks] Re: Amazon Interview Question

2013-04-30 Thread Gary Drocella
Counting sort does not run in O(1) space though. Optimally it will run in O(K) space, where A is an array of integer numbers and K = max(A) - min(A) On Saturday, February 9, 2013 9:52:01 PM UTC-5, Mohanabalan wrote: can use counting sort On Sun, Jul 15, 2012 at 6:37 PM, santosh thota

Re: [algogeeks] Re: Amazon Interview Question

2013-04-30 Thread Gary Drocella
A bit vector is basically just a sequence of bits such as a word or even an array of words. Here is an example... int x = 5; // 32 bit word size on Intel IA-32 Architecture In C programming language. A variable in C will be either located in a register in memory or in Main Memory. You

[algogeeks] Datastructure Space Complexity

2013-04-29 Thread Gary Drocella
My name is Gary Drocella, age 23, and got my BA in comp. sci. at University of Maryland College Park. I am reading a book for fun on my spare time Multidimensional and Metric Data Structures by Hanan Samet. They are talking about range trees, and they claim that a 1-dimensional range search

[algogeeks] Re: Amazon Interview Question

2013-04-29 Thread Gary Drocella
This will only work if each element in the array are relatively prime to one another, that is for any two elements x, y in array A the gcd(x,y) = 1, which is also just another way of saying no number divides another number in the array. Once this rule is broken, then the algorithm will no

[algogeeks] Re: Datastructure Space Complexity

2013-04-29 Thread Gary Drocella
On Monday, April 29, 2013 4:06:50 PM UTC-8, Gary Drocella wrote: My name is Gary Drocella, age 23, and got my BA in comp. sci. at University of Maryland College Park. I am reading a book for fun on my spare time Multidimensional and Metric Data Structures by Hanan Samet

[algogeeks] Re: RAID LEVEL

2011-08-09 Thread Gary Drocella
RAID Level 0 is used for high performance where data loss isn't critical. Bit stripping is still performed over multiple disks, but no mirroring or parity bits used for checking data integrity. On Aug 9, 2:56 pm, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: On Wed, Aug 10, 2011 at

[algogeeks] Re: C question.. increment decrement operator..

2011-08-07 Thread Gary Drocella
@puneet The provided faq is garbage, if you want to learn about the semantics of the C programming language, then refer to this original ISO spec here http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf I also suggest that for all programming languages (OCaml, Ruby, lua script, etc) It is

[algogeeks] Re: C question.. increment decrement operator..

2011-08-07 Thread Gary Drocella
I thought this was algogeeks, not company question geeks. On Aug 7, 4:27 pm, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: please these questions are compiler dependent and have no standard answers...these are rarely asked by companies On Sun, Aug 7, 2011 at 1:23 PM, Gary

[algogeeks] Re: Google Interview Question

2011-08-01 Thread Gary Drocella
Here is O(n) alg... Does Waste Memory Though :) just don't have an array over 4G, and you should be good. proc Merge_Partition(A) B = {}; index = 0; count0 = 0; count1 = (n/2); while index to A.length B[index++] = A[count0++]; B[index++] = A[count1++]; end while return B end proc On

[algogeeks] Re: Implementation of trie data structure

2011-07-30 Thread Gary Drocella
Knowing The Definition of a Trie Data Structure should be all you need to know how to implement a trie ADT. It's a structure where all the true (key,value) pairs are in the external nodes, and the guide keys/values are in the internal nodes. Examples of Trie Data structures are B+ Trees, B*

[algogeeks] Re: Tug of War

2011-07-30 Thread Gary Drocella
To Solve This Problem, I would 1. Sort the given list S by their respective strengths. 2. Then I would create two other lists A and B for respective partitions. 3. (a) Remove First and Last from S add them both to A (b) Remove First and Last from S add them both to B 4. Repeat Step 3 until

[algogeeks] Probabilistic Analysis and Randomized Algorithms

2011-04-20 Thread Gary Drocella
Hey, I spend most of my time researching systems computing, but these problems are fun and interesting (so bare with me :) This problem is from Chapter 5 of Introduction to Algorithms (MIT Press) 5.1-2 Describe an implementation of the procedure RANDOM(a,b) that only makes calls to RANDOM(0,1).

[algogeeks] Re: Reading Huge input from the terminal in least time.

2011-04-20 Thread Gary Drocella
You could just use a pseudo-random number generator to fill in the array. You may also want to consider the data type (each unsigned int would be 4 bytes, where a unsigned char would be 1 byte). Or, If it's truly necessary to read this much data from the console... You could use unix pipes, (cat