Hint 1: If taken the assumption that you have ~6GB RAM (out of this 3.7GB
is for the input itself) you do not need any external sorting to do this.
Hint 2: 1,000,000,000 (2 30)
Hint 3: Read this http://en.wikipedia.org/wiki/Bit_array#Sorting up
On Thu, Jun 13, 2013 at 2:06 AM, MAC
Can you tell the 'size' of your array 'f' if the intervals are [0, 10],
[10, 9223372036854775808] ?
Programmers should realize their critical importance and responsibility in
a world gone digital. They are in many ways similar to the priests and
monks of Europe's Dark Ages; they are the only ones
Read up on Interval trees http://en.wikipedia.org/wiki/Interval_tree.
Programmers should realize their critical importance and responsibility in
a world gone digital. They are in many ways similar to the priests and
monks of Europe's Dark Ages; they are the only ones with the training and
insight
(For very large k case only)
Keep as many elements in the hash_map as you can. Once the map capacity is
exhausted, sort all the elements in the hash_map and write them to disk and
build a bloom filter. Keep this bloom
filterhttp://en.wikipedia.org/wiki/Bloom_filterin memory, empty the
hash_map
and then start with the vertices whose in degree is 1.
Veni Vedi Slumber !
On Fri, May 24, 2013 at 6:19 AM, MAC macatad...@gmail.com wrote:
kindly explain visualizing a balanced BST as a graph and unable to
underdstand your point
thanks
--mac
On Fri, May 24, 2013 at 6:04 AM, Avi
Code is here http://codebin.org/view/30e9f2c0. Logic is made clear by the
variable names. Idea is similar to the one which is used to build a queue
using 2 stacks.
On Wed, May 22, 2013 at 8:45 AM, MAC macatad...@gmail.com wrote:
I think this is only possible if you make sure that at push you
On Sat, May 11, 2013 at 10:29 AM, Aman Jain pureama...@gmail.com wrote:
2. from this no*de u*, again apply* dfs* to find longest distant node
from this node.Let us say that node is v.
Small doubt about the solution. Consider this graph a - b - c - d
You randomly choose vertex 'b' and do a
#include stdio.h
#include string.h
#include stdlib.h
int main() {
int n, num, i;
scanf(%d, n);
for (i = 0; i n; ++i) {
char ch = '#';
printf(scanned from %d line: , i + 1);
while (ch != '\n') {
scanf(%d%c, num, ch);
printf(%d , num);
}
printf(\n);
}
#include cstdio
#define NULL1 (void *)0
#define NULL2 0
int main() {
int* p = NULL1; // void* being assigned to a int*, C++ complains.
int* q = NULL2;
return 0;
}
Veni Vedi Slumber !
On Sat, Jul 2, 2011 at 10:28 PM, Decipher ankurseth...@gmail.com wrote:
Hey I was asked this question
Another alternative soln.
int rec_cut(int l, int k) {
if (l == k) return 0;
int tmp = k - (l1);
return 1 + rec_cut(l1, tmp = 0 ? k : tmp);
}
int main() {
int l, k;
scanf(%d%d, l, k);
printf(%d\n, rec_cut(l, k));
return 0;
}
Veni Vedi Slumber !
On Sat, Jul 2, 2011 at 9:47 PM,
extending the above example
Base B;
DerivedClasses D1, D2;
B's content - {content_of_B }
D1's content - { content_of_B, D1_specific_data_and_functions}
D2's content - { content_of_B, D2_specific_data_and_functions}
Can you see the reason now? The above is a very simplified example, think of
@^ Just check ur solution for boundary case ( n = 2) .. M$ is *generally*
very strict about such mistakes :)
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks
of Europe's Dark Ages; they are the
at index 1, 2 and 3... go greedy on
f(index) = index + array[index]
so f(1) = 1 + 5 = 6
f(2) = 2 + 3 = 5
f(3) = 3 + 4 = 7
plainly, if u define ur greedy criteria right, u go for index 3...
On Jan 15, 11:15 pm, Avi Dullu avi.du...@gmail.com wrote:
The greedy will always chose
initially said greedy would make wrong choices 3-5-4 and hence
give wrong minimum number of jumps while DP would give 3-4... hence i
responded saying that if we go greedy on a different function, greedy
will yield the right result as well... and in a shorter time
On Jan 16, 12:28 pm, Avi Dullu
and jump there.
This greedy approach works in 0(n^2) and i believe it works. If not
can
someone give me a counter example ?
On Sat, Jan 15, 2011 at 3:30 AM, Avi Dullu avi.du...@gmail.com
wrote:
@jammy Even I felt the same, but the greedy 'algo' u suggest is
actually
IMHO
move forward...
On Jan 15, 12:54 pm, Avi Dullu avi.du...@gmail.com wrote:
@jammy Thanx for the elongated description :)
Yes, I feel I probably gave a DP solution wrongly to the Greedy approach.
But just to clarify, Greedy does not solve any subproblems, it just makes
a
locally optimal
I guess u got confused with the comment I wrote, I have added 2 print
statements and now I guess it should be clear to you as to why the code is
O(n). The comment means that each element of the min_steps_dp will be
ACCESSED only ONCE over the execution of the entire program. Hence the outer
loop
since you can't ensure the choice is
locally optimum. Consider 3,9,2,1,8,3. Using greedy alg. would give
you 3,1,8,3 while otherwise DP would give you 3,9,3.
On Jan 14, 6:11 am, Avi Dullu avi.du...@gmail.com wrote:
I guess u got confused with the comment I wrote, I have added 2 print
SO .. u guys propose that 'sorting' is an O(1) space ? Won't the sorting
algo swap elements of the list so making it a O(n) space algo ? (Just
proposing :) )
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the
Sure, I raised concern about 'sorting'.
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks
of Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the
@juver++ : what is the greedy approach one could take here? I know it would
be wrong, but I tried to come up with a test case for greedy failure, but
realized the greedy policy here will be equivalent to the dp.
@Decipher: your's seems to be a O(n^2) solution. Here in the O(n) version of
it.
Hey guys .. saw this discussion and wanted to add something .. I wrote the
below program in college .. and I kindof have forgotten wat was the logic
(see the problem with badly written code :P ), It works on a pattern which I
found in this problem, I checked it and feel it works in order O(n) as
to add to @Dave's reply. He explained it elaborately in
thishttp://groups.google.com/group/algogeeks/browse_thread/thread/20af6e098297d413thread
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks
One approach would be to convert both the trees to well formed flat-tree
representation and then reduce the problem to a substring matching one (can
use KMP/Boyer-Moore/Rabin-Karp for it).
eg.
1
2 3
4 5
is flattened to (using postorder traversal) (1 (2 4 .) (3 . 5))
Programmers
correct and recommended way is missing an absolute value:
assert(abs(d1 + d2 - d3) 1.0e-5); // given you assume precision of
1e-5 is the correct and recommended way.
Dave
On Jan 6, 4:19 pm, Avi Dullu avi.du...@gmail.com wrote:
Just to mention, floating point numbers r always compared
depends in part on whether
you want to say that 0.2 == 0.29 because they differ by less
than 1.0e-5, even though they differ by 45%. Applying your
philosophical boilerplate, you have to use some intelligence even in
this type of thing.
Dave
On Jan 7, 12:51 pm, Avi Dullu avi.du...@gmail.com
@Decipher
As far as I understand the problem it says returns the 5 most common
occuring strings in a list, and the example u give is of a character array,
when u go to a list of strings with len_of_each_string 1, u wil have to
*hash* them, which is when u will run into problems with count sort.
Hey,
Remembered of my OS assignment and wanted to fix it :). Though do not
appreciate the design of the program :D, and not having the enthu to
redesign it, I have fixed the program with minimal possible changes. Please
reply in case of any issues. Thnx for posting :)
#include iostream
#include
Just to mention, floating point numbers r always compared *for equality*
like
double d1 = 90.0;
double d2 = 90.0;
assert(d1 == d2); // might fail, and Wrong way to do !!
assert(d1 - d2 1e-5); // given u assume precision of 1e-5, is the correct
and recommended way.
Programmers should realize
29 matches
Mail list logo