[algogeeks] Renaming namespaces c++

2013-07-30 Thread Arun Vishwanathan
Hi all, I went through the following post on Stack overflow: http://stackoverflow.com/questions/6108704/renaming-namespaces but I have questions on the solution given, The question mentions about change of namespace from old to _new::nested for the class because of which any reference to

[algogeeks] why does this work?

2013-07-18 Thread Arun Vishwanathan
I tried the following on ideone #include stdio.h int main(){ int *temp; printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(value is %p\n,temp); return 0;} it prints that : value is (nil) which am assuming is NULL if I try to print *temp it gives me segv

Re: [algogeeks] Pointers Usage

2013-01-03 Thread Arun Vishwanathan
@atul/shady: why is it that pointer takes 8 bytes ? So the takes a memory location whose value is the address of the element it points to. Why does the pointer value have to take 8 bytes? I am sorry if I am missing something silly here. On Thu, Jan 3, 2013 at 3:11 AM, Debabrata Das

Re: [algogeeks] Re: parameters to non-const and const reference concept-C++

2012-12-23 Thread Arun Vishwanathan
@Lucifer: Thanks a lot for the explanation On Sun, Dec 23, 2012 at 4:51 AM, Lucifer sourabhd2...@gmail.com wrote: @phoenix The reason is not an implication of using references. If u are passing emptyvec() as an argument then the vector returned by emptyvec() is a temp object ( as its not

[algogeeks] parameters to non-const and const reference concept-C++

2012-12-22 Thread Arun Vishwanathan
Hi, Could someone explain the logic behind the following: Arguments that correspond to non-const reference parameters must be lvalues-that is they must be non-temporary objects. Arguments that are passed by value or bound to a const reference can be any value Suppose a function returns an empty

Re: [algogeeks] finding element in array with minimum of comparing

2012-10-08 Thread Arun Vishwanathan
@Dave: Nice solution. Can you clarify why you need to store the first element in a temp variable and put 'elem' in the first position? If elem was already first in array then it makes no difference. If elem was not first but somewhere in between, the loop will break there when coming from behind

Re: [algogeeks] GPU doubt

2012-04-08 Thread Arun Vishwanathan
Thanks IIya On Sat, Apr 7, 2012 at 3:53 PM, Ilya Albrekht ilya.albre...@gmail.comwrote: I'm absolutely didn't get your explanation... What is the connection between O(n^3) algorithms and staff you are talking about? On Saturday, 7 April 2012 03:22:29 UTC-7, SAMMM wrote: This is becoz the

Re: [algogeeks] GPU doubt

2012-04-07 Thread Arun Vishwanathan
@SAMM: what about general mathematical computations such as matrix multiplication which is O(n^3) as such? How do you relate your explanation to such math computations or any algorithm of atleast O(n^3)? On Sat, Apr 7, 2012 at 3:22 AM, SAMM somnath.nit...@gmail.com wrote: This is becoz the GPU

Re: [algogeeks] hadoop anyone?

2012-03-31 Thread Arun Vishwanathan
@karthikeyan: Thanks for that info. So in the sample wordcount program using Hadoop pipes in c++ if i want to see data each node has got, I shd query namenode? Is namenode a class or something which contains information or which variable should I check out? Thanks On Sat, Mar 31, 2012 at 2:23 AM,

Re: [algogeeks] hadoop anyone?

2012-03-31 Thread Arun Vishwanathan
@karthikeyan: Thanks again but I was looking to find that information out from writing code to do so than to use a command on the command line prompt.Any idea? On Sat, Mar 31, 2012 at 10:40 AM, Karthikeyan V.B kartmu...@gmail.comwrote: @bharat : hadoop has a* job tracker* which *resolves the

[algogeeks] hadoop anyone?

2012-03-29 Thread Arun Vishwanathan
Hi all, Has anyone worked on Hadoop before? I ran the wordcount program with Hadoop but I am unable to understand how to find out which node in the cluster got which data? Any experts out here who can suggest? Arun -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: need suggestions

2012-03-28 Thread Arun Vishwanathan
subset of remaining items. Each processor should be able to work fairly independently, and when they are done, they can compare results and find the best one. Don On Mar 27, 10:47 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote: Hi all, I am planning to implement a parallel version

Re: [algogeeks] Re: need suggestions

2012-03-28 Thread Arun Vishwanathan
their portion of the work. Don On Mar 28, 9:51 am, Arun Vishwanathan aaron.nar...@gmail.com wrote: @Don: I am not clear with your explanation. Please can you give me an example? On Wed, Mar 28, 2012 at 6:19 AM, Don dondod...@gmail.com wrote: If you have n processors, start

[algogeeks] need suggestions

2012-03-27 Thread Arun Vishwanathan
Hi all, I am planning to implement a parallel version of the 0-1 knapsack problem. I tried reading up a bit and there are few suggestions here and there. However I would like to know if anyone has an idea or links that I cud refer for this? The main problem in parallelizing a DP algorithm is the

Re: [algogeeks] Re: optimisation

2012-03-05 Thread Arun Vishwanathan
a sample and I think I got somewhat good speedup for block size 32 ( for matrix dimension 512, 1024 etc )for my L1 of size 16 kbytes and L2 256 kbytes...Any comments or inferences? On Wed, Feb 29, 2012 at 9:31 AM, Arun Vishwanathan aaron.nar...@gmail.comwrote: @all: Thanks a lot On Wed, Feb

Re: [algogeeks] Re: optimisation

2012-02-29 Thread Arun Vishwanathan
the sums in the best possible manner. FWIW, a GPU will normally outperform a general purpose CPU with ease on this problem. Since even cell phones are getting GPUs these days, tweaking single-processor matrix code is a dying art. Cheers. On Feb 27, 6:57 pm, Arun Vishwanathan aaron.nar

[algogeeks] optimisation

2012-02-27 Thread Arun Vishwanathan
Hi all, We have this challenge to make the fastest executing serial matrix multiplication code. I have tried using matrix transpose( in C for row major ) and loop unrolling.I was able to obtain little speedup. Does anyone have any hints/papers that I could read upon and try to speed up further?I

[algogeeks] suggestions?

2012-02-12 Thread Arun Vishwanathan
hi, I need to a final project in a course called Parallel Programming. Does anyone have suggestions for a good topic to take up in this??Some challenging problem maybe that is computationally intensive but can benefit from multicore and parallel processing. Thanks! -- People often say that

Re: [algogeeks] Re: suggestions?

2012-02-12 Thread Arun Vishwanathan
(as in mechanical design tools, CGI, and computer games). On Feb 12, 10:58 am, Arun Vishwanathan aaron.nar...@gmail.com wrote: hi, I need to a final project in a course called Parallel Programming. Does anyone have suggestions for a good topic to take up in this??Some challenging problem maybe

[algogeeks] openmp

2012-02-05 Thread Arun Vishwanathan
hi , i am trying to run this small code with open mp but I dont see any threads created . The code compiles with -fopenmp but does not create threads to run parallel.For example, main() { omp_set_num_threads(4); #pragma omp parallel printf( hello world from %d\n ,omp_get_thread_num());

Re: [algogeeks] openmp

2012-02-05 Thread Arun Vishwanathan
I use g++ On Sun, Feb 5, 2012 at 12:39 PM, Rahul raikra...@gmail.com wrote: which compiler or which environment I use Microsoft Visual Studio with Microsoft HPC Pack A syntax error is visible use { On 2/6/12, Arun Vishwanathan aaron.nar...@gmail.com wrote: hi , i am trying to run

Re: [algogeeks] openmp

2012-02-05 Thread Arun Vishwanathan
running without asking number of threads .you must see as many outputs as number of processors On 2/6/12, Arun Vishwanathan aaron.nar...@gmail.com wrote: I use g++ On Sun, Feb 5, 2012 at 12:39 PM, Rahul raikra...@gmail.com wrote: which compiler or which environment I use Microsoft

[algogeeks] java help

2012-02-02 Thread Arun Vishwanathan
Hi, does anybody know how to take a screenshot of screen with java ? I also need help regarding storing the screenshot image into a doc file or so. Any suggestions? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Mathematical formula

2012-01-28 Thread Arun Vishwanathan
I wanted to gather some analysis on parallelism for matrix multiplication. Amdahl 's law essentially compares speed when work is done serially to speed when some parallelism is introduced in the system. Say I have Tcount threads used for computation on a system having NCores number of cores. Say

Re: [algogeeks] MS Question -Reverse a Linked List in size of 2

2012-01-23 Thread Arun Vishwanathan
node *ptr =head; //function call is reverse(head,NULL) void reverse(node *ptr, node *follow) { if(ptr-next!=NULL ptr-next-next!=NULL) reverse(ptr-next-next,ptr); else if(ptr-next!=NULL ptr-next-next==NULL) { ptr-next-next=follow; head=ptr; }

Re: [algogeeks] Re: sort 2D array

2012-01-22 Thread Arun Vishwanathan
@lucifer:nice explanation !... just to make a small clarification, in your stabilisation part u jus compare x with min (b,d) , make a swap if necessary and then next time u compare it shud be =min(b,d) and so u break. x b c d e f g h i so now after breaking x is less than both b

Re: [algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-22 Thread Arun Vishwanathan
@lucifer: in yr code will not all the root-left be NULL for each iteration as startindex is always greater than endindex ( i.e i-1) in the recursive function call??and so for each node only root-right is made? On Fri, Dec 30, 2011 at 12:51 AM, praveen raj praveen0...@gmail.com wrote: yes...

Re: [algogeeks] Re: sort 2D array

2012-01-22 Thread Arun Vishwanathan
, the swaps go on till the condition x = min (b,d ) is not satisfied.. On Jan 23, 3:44 am, Arun Vishwanathan aaron.nar...@gmail.com wrote: @lucifer:nice explanation !... just to make a small clarification, in your stabilisation part u jus compare x with min (b,d) , make a swap if necessary

Re: [algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-22 Thread Arun Vishwanathan
is no. The above condition basically identifies that we have reached a leaf node and hence, the leaf node should have both its left and right pointers set to NULL. If you trace it. you will figure it out. In case there is a doubt do let me know.. On Jan 23, 4:17 am, Arun Vishwanathan aaron.nar

Re: [algogeeks] Re: sort 2D array

2012-01-22 Thread Arun Vishwanathan
happens.. b x c d e f g h i say, x min(c, e), where min(c,e) = e.. Hence, swap takes place.. b e c d x f g h i Now say, x = min(f,h).. Hence, we hit the break statement and exit from the loop.. On Jan 23, 5:03 am, Arun Vishwanathan aaron.nar...@gmail.com wrote

Re: [algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-22 Thread Arun Vishwanathan
'.. Try doing it for i = startIndex + 3 (say).. and also ensure that when you go inside recursively try to trace the case where 'i startIndex + 1' and see if you get it.. On Jan 23, 5:11 am, Arun Vishwanathan aaron.nar...@gmail.com wrote: @lucifer: sorry if i seem

Re: [algogeeks] Re: Divisibility by five

2012-01-21 Thread Arun Vishwanathan
@dave or anyone: can u pls explain the logic of n3 in dave's solution? why is it subtracted from n(which is divided by 4 using 2) and what does n 3 indicate? On Sat, May 7, 2011 at 9:38 AM, Dave dave_and_da...@juno.com wrote: @Umer: Do you suppose that you can convert an int into a string

Re: [algogeeks] how to convert a floating point number into binary representation.

2012-01-21 Thread Arun Vishwanathan
@immanuel: in this part while (decimalPart 0 decimalPart 1 str.length 64) { decimalPart *= 2; str[str.length] = (decimalPart - 0) + '0'; } is this decimalPart-0 correct here? if decimalpart (say) starts as 0.584 then after doing that into 2 we 1.164. What happens

Re: [algogeeks] Re: distinct substring

2012-01-21 Thread Arun Vishwanathan
@juver: further explanation? On Tue, Jan 25, 2011 at 6:27 AM, juver++ avpostni...@gmail.com wrote: suffix trees. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Re: google questions

2012-01-21 Thread Arun Vishwanathan
@all: how is the problem solved using a heap...can someone explain. did not understand what was on the net... On Thu, Feb 3, 2011 at 2:23 AM, Avik Mitra tutai...@gmail.com wrote: I am proposing a solution for problem 2.. 2. Given a text file, implement a solution to find out if a pattern

Re: [algogeeks] Re: Divisibility by five

2012-01-21 Thread Arun Vishwanathan
divisibility by 5? Dave On Jan 21, 9:25 am, karthikeyan muthu keyankarthi1...@gmail.com wrote: @dave int no=10; char ans[100]; sprintf(ans,%d,no); coutans; On Fri, Jan 20, 2012 at 10:29 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: @dave or anyone: can u pls

Re: [algogeeks] Re: vertical level sum in Binary tree

2012-01-21 Thread Arun Vishwanathan
my god why do companies question like this??? On Sat, Jan 21, 2012 at 4:10 AM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: yes atul I wanted to say only that may be not able to convey it . n is maximum number of vertical lines sum that you can calculate On 1/21/12, atul anand

Re: [algogeeks] Re: vertical level sum in Binary tree

2012-01-21 Thread Arun Vishwanathan
no jst thinking if any practical application of this sort of thing..:) On Sat, Jan 21, 2012 at 3:11 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: why arun? On Sun, Jan 22, 2012 at 1:44 AM, Arun Vishwanathan aaron.nar...@gmail.com wrote: my god why do companies question like

[algogeeks] anybody having K and R ebook?

2012-01-19 Thread Arun Vishwanathan
hey sorry if it seems offtopic to post here...but does anybody have an ecopy of this book?I tried searching but cudnt find one properly. thanks in advance! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: Amazon - Longest palindrome in a string in O(n)

2012-01-19 Thread Arun Vishwanathan
@varun : isn't the longest common subsequence abccba and longest common substring is abc or cba?in any case what is the longest palindrom in the given string abcdecba?? isnt it the individual letters itself ie length max is 1? On Wed, Jun 22, 2011 at 10:45 AM, varun gupta varun.gt...@gmail.com

Re: [algogeeks] Re: Sorting for large data

2012-01-18 Thread Arun Vishwanathan
@ all : can someone provide me a good link to reading on external sort? and k way merging? is this also a useful way to sort when the number of records is large compared to memory size but many entries in the records are repeated elements? On Tue, Jan 17, 2012 at 6:42 AM, sravanreddy001

[algogeeks] MS question

2012-01-18 Thread Arun Vishwanathan
Given large number of elements. All elements belong to range 1 to 27000. First case no elements repeated and second case elements are repeated. memory capacity is 4k. How to sort efficiently? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] Re: adobe written round que

2012-01-18 Thread Arun Vishwanathan
@all : doesnt sudhir's solution seem to work?? @sudhir: can u explain yr logic? On Wed, Sep 21, 2011 at 8:31 AM, annarao kataru kataruanna...@gmail.comwrote: can u explain the logic behind this thanks in advance -- You received this message because you are subscribed to the Google

Re: [algogeeks] Re: Doubt in C++

2012-01-03 Thread Arun Vishwanathan
the value 'test' and then assign to s2... Once, assignment operation is over, the temporary string object containing the value 'test' will be destroyed.. On Jan 3, 12:05 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote: I just have a basic doubt..does the string s1,s2 statement call any default

Re: [algogeeks] Re: sqrt function...

2012-01-03 Thread Arun Vishwanathan
@gene: I checked the wiki link given..In that it is mentioned that initial root is chosen as 2.10^n or 6.10^n based on the number of digits being even or odd in the number. The concept of choosing 2 or 6 in this formula is based on some geometric mean concept mentioned. Can you please clarify what

Re: [algogeeks] Re: Doubt in C++

2012-01-03 Thread Arun Vishwanathan
of '=' has a derieved class type... On Jan 3, 7:52 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote: @lucifer: ok so you are saying that the constructor implicitly creates a temporary 'string' object to hold this char string which is then assigned to s2. Does this mean that if a constructor

Re: [algogeeks] C output????

2012-01-03 Thread Arun Vishwanathan
actually is there any reason as to why same address is returned to the pointer when both pointers(p and q) are initialised to persons unlike when p[] and q[] =persons? On Tue, Sep 6, 2011 at 9:08 AM, Sandy sandy.wad...@gmail.com wrote: String constants (literals) are saved into the .data

Re: [algogeeks] Explanation

2012-01-03 Thread Arun Vishwanathan
@Vrashabh: yea the explanation is kinda difficult to follow since f(1,2) is once done first and once is not though the expressions look similarcan u pls explain what decides the order of evaluation here On Mon, Aug 29, 2011 at 6:23 AM, kartik sachan kartik.sac...@gmail.comwrote: see the out

Re: [algogeeks] Re: String passing

2012-01-03 Thread Arun Vishwanathan
if instead of passing hello directly to function if we passed char array p then this would not show as an error right? and why is this so? is it due to the fact tat p array was not possibly allocated in the read only segment of memory and hence when passed it can be modified by function? so if

Re: [algogeeks] Re: convert into palindrome

2012-01-02 Thread Arun Vishwanathan
@lucifer: can you please give a small example and explain? Now, all we need to do is sequentially access the list and do the following: Given 2 pairs (xi, yi) and (x i+1, y i+1), We will insert RevStr(yi .. y i+1) , excluding the extreme chars, just before Str(x i+1)... On Fri, Dec 16, 2011 at

Re: [algogeeks] Amazon Interview Question

2012-01-02 Thread Arun Vishwanathan
@utkarsh: in yr code it shud be two-- after the swap function and not before for case 2 On Thu, Nov 10, 2011 at 1:25 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: sorry it was incomplete On Fri, Nov 11, 2011 at 2:53 AM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: one = zero =

Re: [algogeeks] Amazon Interview Question

2012-01-02 Thread Arun Vishwanathan
also I dont think that for case 0 we do not need to have one ++. I guess it fails for this example 2200101 On Mon, Jan 2, 2012 at 5:36 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: @utkarsh: in yr code it shud be two-- after the swap function and not before for case 2 On Thu, Nov 10

Re: [algogeeks] Doubt in C++

2012-01-02 Thread Arun Vishwanathan
I just have a basic doubt..does the string s1,s2 statement call any default constructor?or is it that it is not performed since parameterised constructor is present? On Wed, Sep 21, 2011 at 1:31 AM, vijay singh vijaysinghb...@gmail.comwrote: It is because of the presence of the single

Re: [algogeeks] Sum of Four Numbers in an Array (Amazon)

2012-01-01 Thread Arun Vishwanathan
does this make sense? 1)sort array O(nlogn) 2)keep 4 pointer to last 4 elements of array. At each point in the algorithm we need to ensure than ijkl where i j k and l are positions of the 4 pointers. 3)if(sum of those 4 elements k) there exists no such combination else do binary search with all

Re: [algogeeks] Re: given a stream of numbers FIND MEDIAN

2011-12-26 Thread Arun Vishwanathan
@lucifer: can you explain to me in the current median calculation why if there is a Diff =1 or -1 you are using M and top(maxh) or M and top(minh) for median calculation. If the number of elements from the stream so far is odd then median is just one element and not average of 2 elements right?

Re: [algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-22 Thread Arun Vishwanathan
@atul: can you explain what this is doing? for(i=0;in;i++) { pre=reverse(root-children[i],NULL); if(pre) { pre-children[i]=root; } } when u do tree reversal I see that child points to

Re: [algogeeks] Return index of first mismatch bracket ( or )

2011-12-20 Thread Arun Vishwanathan
@shady: I guess first mismatch means the innermost open brace that doesnt have a close brace. U cannot know that the first brace does not have a closing one unless u look at the entire string. On Tue, Dec 20, 2011 at 9:23 AM, shady sinv...@gmail.com wrote: ( ( ) ( ( ) ( ( ) ) ( ) for this

Re: [algogeeks] find numbers if pair wise sums are given

2011-12-13 Thread Arun Vishwanathan
how is the case taken of when 2 pairs add to the same sum?... On Tue, Dec 13, 2011 at 11:35 AM, atul anand atul.87fri...@gmail.comwrote: hmmm i guess i screwed by taking least element as a part of the output set directly. On Wed, Dec 14, 2011 at 12:57 AM, sayan nayak

[algogeeks] median from continuous stream

2011-11-08 Thread Arun Vishwanathan
Hi to find running median from a stream of random generated numbers I have heard of the 2 heap ( min and max heap ) solution but I fail to understand it...could someone please explain with a small example or so ?? thanks! -- People often say that motivation doesn't last. Well, neither does

Re: [algogeeks] Re: Searching In a large file

2011-10-29 Thread Arun Vishwanathan
can someone give me a short explanation of Dave solution? I understand that a[n%10] 1 is trying to find the bin which has less than what maximum numbers it can hold and the bin is such that all numbers counted in this have the same remainder when divided by 10. I do not get the

[algogeeks] finding anagrams in file

2011-10-18 Thread Arun Vishwanathan
Hi all, How to find all the anagrams in a large file containing n words and max length of a word is m letters?? so if file contains add dad abc ced cba it shud say adc dad are anagrams and abc cba are anagrams. time needed is 0(nlogn) -- People often say that motivation doesn't last.

Re: [algogeeks] Re: finding anagrams in file

2011-10-18 Thread Arun Vishwanathan
Hmm I see but if there are m max letters in each word and there are n words in the file, then each word sort is O(mlogm) and for n words so wont it be O(nmlogm)? On Tue, Oct 18, 2011 at 12:55 PM, WgpShashank shashank7andr...@gmail.comwrote: Sort the all the string , Calculate hash-value , if

Re: [algogeeks] Re: finding anagrams in file

2011-10-18 Thread Arun Vishwanathan
also what would be a suitable hash function for the string? On Tue, Oct 18, 2011 at 1:21 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: Hmm I see but if there are m max letters in each word and there are n words in the file, then each word sort is O(mlogm) and for n words so wont it be O

[algogeeks] complement

2011-09-18 Thread Arun Vishwanathan
Hi all, When I take negation of an integer in C, 0 is displayed as -1 ~5 is displayed as -6. Can some one tell me the logic of how this conversion is happening in C? Arun -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Re: complement

2011-09-18 Thread Arun Vishwanathan
= 0 to n-1 of ((1 - bi) * wi), where 1 - bi is the complement of bit i, i.e., ~bi. Then V + ~V = sum from i = 0 to n-1 of wi since bi cancels -bi for every i. The sum of the weights is -1. Thus, V + ~V = -1, from which -V = ~V + 1. Dave On Sep 18, 5:26 pm, Arun Vishwanathan aaron.nar

Re: [algogeeks] Re: Remove all Duplicates Words

2011-08-25 Thread Arun Vishwanathan
@anup: can u provide a sort of pseudocode as to how ur code is O(n)?firstly u need to find out which word might have a repetition. so u compare first character of first word with all the other first characters.if there is not repetition , then u have to compare first character of second word with

Re: [algogeeks] Re: C doubt

2011-08-24 Thread Arun Vishwanathan
this. Otherwise, declare an integer pointer in the struct and use malloc to allocate memory for it. Then you can use it like an array. Don On Aug 23, 11:51 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote: say that you have a structure with some fields of known size and unknown size.For

[algogeeks] C-hexadecimal doubt

2011-08-24 Thread Arun Vishwanathan
Hi all, I need to store a hexadecimal value in C( which would be used as a request type in a network) of around 4digits( or 16 bits-2 bytes ) in a packet structure.If my system keeps 4 bytes for an integers, is it necessary that I have to declare the hex value as of type short int or so, so that

Re: [algogeeks] Re: C-hexadecimal doubt

2011-08-24 Thread Arun Vishwanathan
adjacent elements in the structure which can be combined into one word. Don On Aug 24, 1:07 pm, Arun Vishwanathan aaron.nar...@gmail.com wrote: Hi all, I need to store a hexadecimal value in C( which would be used as a request type in a network) of around 4digits( or 16 bits-2 bytes

[algogeeks] C doubt

2011-08-23 Thread Arun Vishwanathan
say that you have a structure with some fields of known size and unknown size.For example, a char, an integer and an integer array.I do not know the size of the integer array until the user mentions the number of bytes he needs this integer array to cover in the command line as an argument.Is it

Re: [algogeeks] Re: Puzzle

2011-08-20 Thread Arun Vishwanathan
@DK:if L is married to M according to you finally , then what does the third if then statement according to you mean when it is given that if L is not married then M is married? On Fri, Aug 19, 2011 at 10:35 PM, Dave dave_and_da...@juno.com wrote: @DK: What in the statement of the problem led

[algogeeks] duplicate elements

2011-08-19 Thread Arun Vishwanathan
in an earlier post there was a discussion in which a person had asked to find the duplicate element in an array of integers in o(n) time and o(1) space... there was a solution using xor that was provided if all numbers in the range from 1-n with one repeating element were present in the array.

Re: [algogeeks] Re: print all paths which sum up to a value.

2011-08-19 Thread Arun Vishwanathan
@mac: just to clear my understanding, u need to print paths that sum up to a Value which means the value of the nodes in a path is added right to see if it satisfies this Value? does the value at each node have any relevance as such? I mean can it be any value at any node or does value at a node

Re: [algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-19 Thread Arun Vishwanathan
@dave: actually how did u get the approach to this? I mean why did u have to do the q|=1 in the if(a=b) condition and q=1 always in the loop? On Fri, Aug 19, 2011 at 1:46 PM, Sanjay Rajpal tosanjayraj...@gmail.comwrote: @Shashank : Would you throw some light on how you determined the complexity

Re: [algogeeks] Re: longest repeated substring

2011-08-18 Thread Arun Vishwanathan
am just asking but how can u get all possible substrings in O(n square) time when there are 2 power N of them actually? On Thu, Aug 18, 2011 at 4:20 PM, DheerajSharma dheerajsharma1...@gmail.comwrote: O(n^2) i guess.. We can save all possible substrings..(in two loops it can be done) in a

Re: [algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-18 Thread Arun Vishwanathan
@dave: in your algorithm, I have a doubt in the second loop( for loop ). q=0 initially so the first q1 stays zero and then q|=1 makes q=1 now. 1 then becomes x 2 and then again with the OR 2 becomes 3. 3 becomes 6 and with the OR 6 becomes 7. for example if i need to do 24/3, according to the

Re: [algogeeks] reason

2011-08-18 Thread Arun Vishwanathan
@programming love:I can understand what u say but my doubt is that for the first output which is 2, according to your example, p has address 10 which it points to.And as u say int * tends to dereference 2 bytes so that wud be now 10 and 11.finally char * takes only 1 byte so why is value at 11

Re: [algogeeks]

2011-08-14 Thread Arun Vishwanathan
so according to the discussions above input should start with and end with but also there is a thing that input is accepted until is encountered.Is not this contradicting? On Sun, Aug 14, 2011 at 3:13 PM, shady sinv...@gmail.com wrote: no, input should start and end with a On Sun, Aug 14,

Re: [algogeeks] c question!

2011-08-11 Thread Arun Vishwanathan
hmm ya am sorry abt that..what abt the first part i mentioned...how is it (nodeptr*)malloc according to you (which is creating a pointer to a pointer type nodeptr )rather than just nodeptr which is a pointer to structure? how to get size of structure as such in this case? On Thu, Aug 11, 2011 at

Re: [algogeeks] Jumping Puzzle

2011-08-11 Thread Arun Vishwanathan
I did not get the optimal solution part..how is that u jump 1 to index 1? On Thu, Aug 11, 2011 at 10:07 AM, Algo Lover algolear...@gmail.com wrote: Given an array, start from the first element and reach the last by jumping. The jump length can be at most the value at the current position in

Re: [algogeeks] c question!

2011-08-10 Thread Arun Vishwanathan
@siddarth: should not the statement you mentioned above as nodeptr h = (nodeptr*)malloc(sizeof(nodeptr*)); be nodeptr h =(struct*)malloc(sizeof(struct)); ?? cos malloc returns pointer to memory block and nodeptr itself is a pointer and you have used nodeptr* further? On Tue, Aug 9, 2011 at

Re: [algogeeks] simple doubt

2011-08-10 Thread Arun Vishwanathan
@jiten: that staement means pa is a pointer to 3 ints not an array of pointers.. int *pa[3] means it is an array of pointers On Fri, Aug 5, 2011 at 8:44 PM, Jiten j.playe...@gmail.com wrote: (*pa)[3] ;// pa is array of pointers to int type; so pa = arr; doesn't make any sense ,bcoz arr

Re: [algogeeks] output?

2011-08-10 Thread Arun Vishwanathan
@sandeep: so the statement becomes if(ch=0) since printf returns integer 0...whats does this mean now actually?0 is ascii for NULL and so ch is assinged to null? I am slightly confused.. On Tue, Aug 9, 2011 at 7:04 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: @all sorry i give wrong

Re: [algogeeks] problem regarding output??

2011-08-10 Thread Arun Vishwanathan
@ankit: does that mean that after the compiler is informed that the void pointer will point to integer witht he typecast statement and then we point it to some other type , it will be an error? i mean after that typecast statement, if i do char a; k=a;is it wrng? On Tue, Aug 9, 2011 at 2:06

Re: [algogeeks] Re: Probability Puzzle

2011-08-09 Thread Arun Vishwanathan
@dave: yes it seems so that 17/18 is correct...I deduced it from the cond prob formula.. I have a minor doubt in general why prob( 2nd toss is a head given that a head occurred in the first toss ) doesnt seem same as p( head in first toss and head in second toss with fair coin) +p(head in

Re: [algogeeks] Re: Paypal interview Questions

2011-08-09 Thread Arun Vishwanathan
@saurabh: are u referring to bit map sort? On Mon, Aug 8, 2011 at 5:51 PM, saurabh singh saurab...@gmail.com wrote: If you limit the magnitude of numbers,it is On Mon, Aug 8, 2011 at 9:02 PM, siva viknesh sivavikne...@gmail.comwrote: is there any possible solution for O(1) space and

Re: [algogeeks] Re: Probability Puzzle

2011-08-08 Thread Arun Vishwanathan
@don: i too get yr answer 17/18 using conditional probability...does that make sense??i guess this is first new answer lol On Mon, Aug 8, 2011 at 9:29 PM, Don dondod...@gmail.com wrote: The answer is 17 in 18, because flipping 5 heads in a row is evidence that the probability is high that we

Re: [algogeeks] Re: Probability Puzzle

2011-08-08 Thread Arun Vishwanathan
@shady: 3/5 can be the answer to such a question: what is prob of getting head on nth toss if we have 4 coins fair and one biased...then at nth toss u choose 4/5 1/5 prob and then u get 3/5 @shady , don: i did this: P( 6th head | 5 heads occured)= P( 6 heads )/ P( 5 heads) answr u get is

Re: [algogeeks] Amazon Question

2011-08-05 Thread Arun Vishwanathan
would u mind giving a short explanation of yr code too if possible? On Thu, Aug 4, 2011 at 5:38 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: I think this should worktell me if this works... void longest_0_1_substring(char *str) { int

Re: [algogeeks] Amazon Question

2011-08-05 Thread Arun Vishwanathan
by the way doesnt it look like an O(n^2) algo? On Fri, Aug 5, 2011 at 10:53 AM, Arun Vishwanathan aaron.nar...@gmail.comwrote: would u mind giving a short explanation of yr code too if possible? On Thu, Aug 4, 2011 at 5:38 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: I think this should

Re: [algogeeks] max product of a subarray

2011-08-05 Thread Arun Vishwanathan
it is difficult to read code and understand but based on the logic u mentioned in 3 points i just want to know if u also have taken care of the case where u have zero points in the array and as u say find each product around 0 points, do u check within each subarray around the zero point if the

Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it just 1/4*1/6=1/24?? On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote: yes it cant be 1/8 I was wrong. On Fri, Aug 5, 2011 at 4:23 PM, coder dumca coder.du...@gmail.com wrote: i think it

Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
oops sorry there On Fri, Aug 5, 2011 at 1:13 PM, aditi garg aditi.garg.6...@gmail.comwrote: @arun he speaks truth 3/4 times On Fri, Aug 5, 2011 at 4:40 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it just 1/4*1

Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
@nitin: oh yes i dint see that coming...good working On Fri, Aug 5, 2011 at 1:49 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: oops sorry there On Fri, Aug 5, 2011 at 1:13 PM, aditi garg aditi.garg.6...@gmail.comwrote: @arun he speaks truth 3/4 times On Fri, Aug 5, 2011 at 4:40 PM

Re: [algogeeks] Amazon Question

2011-08-05 Thread Arun Vishwanathan
with MAX(j-i,max) Surender On Fri, Aug 5, 2011 at 2:25 PM, Arun Vishwanathan aaron.nar...@gmail.com wrote: by the way doesnt it look like an O(n^2) algo? On Fri, Aug 5, 2011 at 10:53 AM, Arun Vishwanathan aaron.nar...@gmail.com wrote: would u mind giving a short explanation of yr

Re: [algogeeks] Re: Puzzle

2011-08-05 Thread Arun Vishwanathan
I guess anubhav soln seems ok On Thu, Aug 4, 2011 at 8:50 PM, ankit sambyal ankitsamb...@gmail.comwrote: @aditi:Thats a non uniform rope. The 1st half may burn faster than 2nd half. btw Priyanka's solution is correct. -- You received this message because you are subscribed to the

[algogeeks] simple doubt

2011-08-05 Thread Arun Vishwanathan
I guess someone had posted a link earlier from which I have a basic doubt when u have int arr[3]={1,0,2}; int **dp; int (*pa)[3]; is this the right assingment for instance? pa=arr; dp=arr; or have I flipped the ampersand in assigning? Also when I do pa++ will it jump by size of int or the

Re: [algogeeks] simple doubt

2011-08-05 Thread Arun Vishwanathan
PM, Arun Vishwanathan aaron.nar...@gmail.com wrote: I guess someone had posted a link earlier from which I have a basic doubt when u have int arr[3]={1,0,2}; int **dp; int (*pa)[3]; is this the right assingment for instance? pa=arr; dp=arr; or have I flipped the ampersand

Re: [algogeeks] simple doubt

2011-08-05 Thread Arun Vishwanathan
then its correct so dp contains addr of p which inturns contains addrof arr now **dp is correct initialization. On Fri, Aug 5, 2011 at 7:45 PM, Arun Vishwanathan aaron.nar...@gmail.com wrote: i see but is not arr a pointer to first array element and so arr contain address of that pointer

Re: [algogeeks] simple doubt

2011-08-05 Thread Arun Vishwanathan
@amol: hmm but I would like to know the reason for it if it is so On Fri, Aug 5, 2011 at 7:50 PM, Amol Sharma amolsharm...@gmail.com wrote: both are wrong.run and see that warning will be displayed !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad

  1   2   >