Re: [algogeeks] Google-Puzzle

2012-02-25 Thread Ashish Goel
max subsum problem Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Feb 25, 2012 at 1:03 PM, karthikeya s karthikeya.a...@gmail.comwrote: You have a circular track containing fuel pits at irregular intervals. The total amount of fuel

[algogeeks] Re: Google-Puzzle

2012-02-25 Thread karthikeya s
buddy i said that kadane's algo(max subsum) wouldn't work.. On Feb 25, 1:31 pm, Ashish Goel ashg...@gmail.com wrote: max subsum problem Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Feb 25, 2012 at 1:03 PM, karthikeya s

[algogeeks] google question

2012-02-25 Thread Ravi Ranjan
|_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| Each cup has capacity C and once a cup gets full, it drops half extra amount to left child and half extra amount to right child for Eg : let' first cups get 2C amount of liquid then extra amount C(2C-C) will be divided equally to left

Re: [algogeeks] Re: Google-Puzzle

2012-02-25 Thread Ashish Goel
it will the diff is of fuel and dist forms the content of array which moves from 1 to 2n-1 elements(break the circle and instead of elem like 1,2,n have 1,2,n,1,2,...n-1 i.e. total 2n-1 so that mod stuff is not required. now find maxsubSum such that sum=0 and count of nodes is n not clear ehy

Re: [algogeeks] Re: array problem

2012-02-25 Thread Amol Sharma
interesting discussion going on the question, check this link-- http://stackoverflow.com/questions/9442958/find-the-element-occurring-b-times-in-an-an-array-of-size-nkb -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99

Re: [algogeeks] Re: ARICENT PATTERN

2012-02-25 Thread vivek kumar
can u provide me some question On Thu, Feb 23, 2012 at 1:59 AM, saurabh tripathi sonu6...@gmail.comwrote: Question in each section varies from 20-25.If u clear this round u have 95% chances because after this round there will b no elimination round. So, all the best.

Re: [algogeeks] google question

2012-02-25 Thread atul anand
i guess this would work... n=number of nodes h=height; pour=quantity poured; capacity = capacity of each cup n=pow(2,h+1) -1; call(capacity,pour,0,n) node* fillCup(float capacity,float pour,int left,int right) { node *root; int mid; if(left right) return NULL; root=(node

[algogeeks] difference b/w static global variables and global variables

2012-02-25 Thread AMAN AGARWAL
Hi , Is there any difference b/w static global variables and global variables ??? (apart from that static variables will be limited to that file only and global variables will be visible for other files also.) Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is

Re: [algogeeks] difference b/w static global variables and global variables

2012-02-25 Thread Akanksha .
Global variable are accessible from other file as well but static global variables are only accessible in that particular file. On Sat, Feb 25, 2012 at 10:21 PM, AMAN AGARWAL mnnit.a...@gmail.com wrote: Hi , Is there any difference b/w static global variables and global variables ???

Re: [algogeeks] difference b/w static global variables and global variables

2012-02-25 Thread rajat ahuja
Scope might be diferent if u define static in function . it will be intilaized once when u call it first time but scope of that variable will be limited to that function only but they live throught out the programe though scope is limited in case of global it can be used in ny function On Sat,

Re: [algogeeks] difference b/w static global variables and global variables

2012-02-25 Thread atul anand
@abv : question sayss.. (apart from that static variables will be limited to that file only and global variables will be visible for other files also.) On Sat, Feb 25, 2012 at 10:44 PM, rajat ahuja catch.rajatah...@gmail.comwrote: Scope might be diferent if u define static in function . it will

[algogeeks] whats the o/p of the code snippet

2012-02-25 Thread AMAN AGARWAL
Hi, int main() { int i; int*p=malloc(4); *p=2; printf(%d\n,*p); free(p); *p=5; printf(%d\n,*p); scanf(%d,i); return 0; } Even though I have freed the memory using free(p) when I am dereferencing it I dont get any seg fault. Can anybody explain me why???

Re: [algogeeks] whats the o/p of the code snippet

2012-02-25 Thread Rahul
Please insert a code snippet in between free and usage That's what I can refer http://stackoverflow.com/questions/9124672/array-desctruction-at-the-end-of-funtion-call On 2/25/12, AMAN AGARWAL mnnit.a...@gmail.com wrote: Hi, int main() { int i; int*p=malloc(4); *p=2;

[algogeeks] output C

2012-02-25 Thread Ravi Ranjan
#include stdio.h #include stdlib.h #define SIZEOF(arr) (sizeof(arr)/sizeof(arr[0])) #define PrintInt(expr) printf(%s:%d\n,#expr,(expr)) int main(int argc, char *argv[]) { /* The powers of 10 */ int pot[] = { 0001, 0010, 0100, 1000 };

[algogeeks] Constructing Binary Tree from a sorted Doubly Linked List

2012-02-25 Thread Supraja Jayakumar
Hi All A sorted doubly linked list is given. We are asked to construct a balanced binary tree. I have designed an n^2 solution. Kindly comment on it and also suggest possible improvements and definitely let me know if something is wrong. Btree* ConstructTreeFromDLList(DLList *dll) { //

Re: [algogeeks] Constructing Binary Tree from a sorted Doubly Linked List

2012-02-25 Thread atul anand
you do the same using bottom up approach...complexity would O(n) On 26 Feb 2012 03:54, Supraja Jayakumar suprajasank...@gmail.com wrote: Hi All A sorted doubly linked list is given. We are asked to construct a balanced binary tree. I have designed an n^2 solution. Kindly comment on it and

Re: [algogeeks] Constructing Binary Tree from a sorted Doubly Linked List

2012-02-25 Thread atul anand
here how you can do it :- call construct(head,0,n-1); n=length of linked list node* construct(node *head,int start,int end) { int mid; if(start end) return NULL; mid=(start+end)/2; node * tleft=construct(dll,start,mid-1); head-next=tleft; head=head-next;

Re: [algogeeks] output C

2012-02-25 Thread atul anand
0001, 0010, 0100, these number are represented in octal ..so u r getting decimal of the same. 1000 - this is a decimal value; preceding number by 0 means you are representing it in octal format similarly preceding 0x means representing in hexa format. On Sun, Feb 26, 2012 at 3:38 AM, Ravi