Re: [algogeeks] Re: C Runtime malloc
On Monday 16 August 2010 06:48:56 Ashish Goel wrote: > do u have a refenrce for that, i am more interested in knowing how heap > manager intracts with VMM Have a look at this: http://mxr.mozilla.org/mozilla-central/source/memory/jemalloc/jemalloc.c Quoting from the Linux malloc(3) page: "Normally, malloc() allocates memory from the heap, and adjusts the size of the heap as required, using sbrk(2). When allocating blocks of memory larger than MMAP_THRESHOLD bytes, the glibc malloc() implementation allocates the memory as a private anonymous mapping using mmap(2). MMAP_THRESHOLD is 128 kB by default, but is adjustable using mallopt(3). Allocations performed using mmap(2) are unaffected by the RLIMIT_DATA resource limit (see getrlimit(2))." mmap() being the interaction you are looking for ... -- Mihai Donțu -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Maximum size binary search tree
Gopinath's solution can be extended by adding one more logic. Do in-order traversal, store it in an array or something. Keep resetting this data-structure if you hit a right leaf or a non-increasing number. Well we will need two such arrays, one for storing the current increasing sequence and other for the previous best. *"These are my principle. If you don't like, i have others."* On Wed, Aug 11, 2010 at 1:44 PM, Divya Jain wrote: > @ above > ur soln ll fail in situation like > 10 > / \ > 15 18 > /\ / \ > 22 7 17 77 > the inorder is > 22 15 7 10 17 18 77 > so the longest increasing sequence is 7-77 > but this is not a bst as 10 n 7 r nt connected > > On 24 June 2010 22:36, gopinath sikha wrote: > >> We can find the solution in O(n) where n is number of nodes. >> Do an in-order traversal of the binary tree. then scan through the numbers >> and find the list and find the longest(increasing or decreasing) sequence. >> That is the size of maximum size of BST in the given binary tree. >> >> >> On Wed, Jun 23, 2010 at 11:40 AM, Raj N wrote: >> >>> Find the maximum size Binary search tree in a binary tree?? >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algoge...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> >> >> >> -- >> -- >> If u doubt your believes,u believe ur doubts >> If u fail to practise,u practises failure >> >> Thanks and Regards >> GopiNath >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Runtime malloc
do u have a refenrce for that, i am more interested in knowing how heap manager intracts with VMM Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Aug 16, 2010 at 9:08 AM, Gene wrote: > There are many different implementations. You should get some > malloc() implementation source codes and study them. You can start > with the GCC rtl. > > > > On Aug 15, 10:52 pm, Ashish Goel wrote: > > A very basic question > > > > what does CRT do when a malloc is done? how the CRT heap manager works > > in conjunction with virtual memory manager? > > > > Best Regards > > Ashish Goel > > "Think positive and find fuel in failure" > > +919985813081 > > +919966006652 > > > > On Sun, Aug 15, 2010 at 10:15 PM, rajat ahuja < > catch.rajatah...@gmail.com>wrote: > > > > > > > > > yup callin destructor ,, deallocate memory of resources > allocated > > > by object > > > like heap memory of pointer ,, > > > > > On Sun, Aug 15, 2010 at 3:58 PM, amit wrote: > > > > >> I have read that Delete is more safer than free as Delete calls the > > >> destructor of the object but i dont get whats the reason for calling > > >> the destructor if anyways it want to deallocate the memory. > > >> Does calling the destructor serves any other purpose?? > > > > >> -- > > >> You received this message because you are subscribed to the Google > Groups > > >> "Algorithm Geeks" group. > > >> To post to this group, send email to algoge...@googlegroups.com. > > >> To unsubscribe from this group, send email to > > >> algogeeks+unsubscr...@googlegroups.com > > > >> . > > >> For more options, visit this group at > > >>http://groups.google.com/group/algogeeks?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To post to this group, send email to algoge...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > algogeeks+unsubscr...@googlegroups.com > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/algogeeks?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: C Runtime malloc
There are many different implementations. You should get some malloc() implementation source codes and study them. You can start with the GCC rtl. On Aug 15, 10:52 pm, Ashish Goel wrote: > A very basic question > > what does CRT do when a malloc is done? how the CRT heap manager works > in conjunction with virtual memory manager? > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > On Sun, Aug 15, 2010 at 10:15 PM, rajat ahuja > wrote: > > > > > yup callin destructor ,, deallocate memory of resources allocated > > by object > > like heap memory of pointer ,, > > > On Sun, Aug 15, 2010 at 3:58 PM, amit wrote: > > >> I have read that Delete is more safer than free as Delete calls the > >> destructor of the object but i dont get whats the reason for calling > >> the destructor if anyways it want to deallocate the memory. > >> Does calling the destructor serves any other purpose?? > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Algorithm Geeks" group. > >> To post to this group, send email to algoge...@googlegroups.com. > >> To unsubscribe from this group, send email to > >> algogeeks+unsubscr...@googlegroups.com >> .com> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/algogeeks?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com > .com> > > . > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Alternative merge
http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6... The best solution given there is O(n) with only constant additional storage. On Aug 15, 1:51 pm, Debajyoti Sarma wrote: > so what was the optimal solution found in the previous discussion?? give a > link > I don't remember the name of the thread...so only i posted this. > > On 8/15/10, Gene wrote: > > > > > In fact this solution was suggested (without code) in the original > > discussion. > > > It's O(n^2). > > > You're only re-ordering a constant number (4) of elements in each > > recursive pass, and each pass requires O(n) time to execute. You also > > need to assume your compiler will remove the tail recursion. > > Otherwise it will also require O(n) space, which misses the whole > > point of the problem. > > > On Aug 15, 12:29 pm, Debajyoti Sarma > > wrote: > >> Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} > >> we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} > >> without using extra buffer space. > >> here a solution i came up withhttp://codepad.org/ub5Ie4sI > >> I know this was discussed before . > >> But i want to know the time complexity of the code i have given(i m > >> confused) > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Alternative merge
http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6fc244a49b/f0214957224b3010 The solution given there is O(n) for certain sizes of input and O(n log n) for general values of n. On Aug 15, 1:51 pm, Debajyoti Sarma wrote: > so what was the optimal solution found in the previous discussion?? give a > link > I don't remember the name of the thread...so only i posted this. > > On 8/15/10, Gene wrote: > > > > > In fact this solution was suggested (without code) in the original > > discussion. > > > It's O(n^2). > > > You're only re-ordering a constant number (4) of elements in each > > recursive pass, and each pass requires O(n) time to execute. You also > > need to assume your compiler will remove the tail recursion. > > Otherwise it will also require O(n) space, which misses the whole > > point of the problem. > > > On Aug 15, 12:29 pm, Debajyoti Sarma > > wrote: > >> Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} > >> we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} > >> without using extra buffer space. > >> here a solution i came up withhttp://codepad.org/ub5Ie4sI > >> I know this was discussed before . > >> But i want to know the time complexity of the code i have given(i m > >> confused) > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Generate all bit strings of length n
well this question is different from the one where recursion makes more sense(telephone dial pad and gereate english char combinations for a given number) int range = 2^n; for int (i=0; i wrote: > Hi, > Can someone gimme the code to generate all possible bit strings of > length n recursively ? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C Runtime malloc
A very basic question what does CRT do when a malloc is done? how the CRT heap manager works in conjunction with virtual memory manager? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Aug 15, 2010 at 10:15 PM, rajat ahuja wrote: > yup callin destructor ,, deallocate memory of resources allocated > by object > like heap memory of pointer ,, > > On Sun, Aug 15, 2010 at 3:58 PM, amit wrote: > >> I have read that Delete is more safer than free as Delete calls the >> destructor of the object but i dont get whats the reason for calling >> the destructor if anyways it want to deallocate the memory. >> Does calling the destructor serves any other purpose?? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Addition Of numbers in SLL
int add(struct node* pL1, struct node * pl2,int gap/*no of digits in l1 -no of digits in l2*/) { //assumption, # of nodes in L1 is > # of nodes in L2, make sure this before calling this, counting nodes is less costlier than reversal if (!(pl1) || !(pl2)) return 0; if (gap>0) { carry = add(pL1->next, pL2, gap-1); carry = (pl1->data+carry)/10; pl1->data =(pl1->data+carry) %10; return carry; } else { carry = add(pL1->next, pl2->next, gap -1); carry = (pl1->data+pl2->data+carry)/10; pl1->data =(pl1->data+pl2->data+carry) %10; return carry; } } Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Aug 15, 2010 at 12:19 PM, Manjunath Manohar < manjunath.n...@gmail.com> wrote: > @Dave..Can u provide a small snippet for ur explanation pls.. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Alternative merge
so what was the optimal solution found in the previous discussion?? give a link I don't remember the name of the thread...so only i posted this. On 8/15/10, Gene wrote: > In fact this solution was suggested (without code) in the original > discussion. > > It's O(n^2). > > You're only re-ordering a constant number (4) of elements in each > recursive pass, and each pass requires O(n) time to execute. You also > need to assume your compiler will remove the tail recursion. > Otherwise it will also require O(n) space, which misses the whole > point of the problem. > > On Aug 15, 12:29 pm, Debajyoti Sarma > wrote: >> Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} >> we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} >> without using extra buffer space. >> here a solution i came up withhttp://codepad.org/ub5Ie4sI >> I know this was discussed before . >> But i want to know the time complexity of the code i have given(i m >> confused) > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Maximum size binary search tree
Space complexity- O(n), Time - O(n2). -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Data Structure for URL matching
Seems a gud idea . I have read we can do better with Ternary Search Trees .Can anybody has any idea about it? On Sun, Aug 15, 2010 at 11:44 PM, Chi wrote: > What you may need is a reverse trie. You may take a look at this: > > > http://phpir.com/tries-and-wildcards > > On Aug 15, 3:21 pm, amit wrote: > > In our indexes, we have millions of URLs each of which has a link to > > some page contents, that is, URL->contents. Now, suppose a user types > > a query with wild cards *, which represent 0 or multiple occurrences > > of any characters, how do you build the indexes such that such a type > > of query can be executed efficiently by finding all corresponding > URLs->contents efficiently. For example, given a queryhttp://www.*o*ve* > ou.com. > > > > You need to find iloveyou.com, itveabcu.com, etc. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Amit Jaspal Btech IT IIIT- Allahabad -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Data Structure for URL matching
What you need is a reverse trie dictionary. You may take a look at this: > http://phpir.com/tries-and-wildcards On Aug 15, 3:21 pm, amit wrote: > In our indexes, we have millions of URLs each of which has a link to > some page contents, that is, URL->contents. Now, suppose a user types > a query with wild cards *, which represent 0 or multiple occurrences > of any characters, how do you build the indexes such that such a type > of query can be executed efficiently by finding all corresponding > URLs->contents efficiently. For example, given a queryhttp://www.*o*ve*ou.com. > > You need to find iloveyou.com, itveabcu.com, etc. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Binary Tree
A binary tree with each node has an additional field node which is initialized to be NULL at first. Asked to, for each node, point its next pointer to the next node in level-by-level traversal order. NO QUEUE should be used HERE! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Maximum size binary search tree
First do a level order traversal.Let the result of level order traversal be stored in a list l (List l = new ArrayList). Then we can do similar to level order once again.There will be two loops. Outer loop will take an element from list l and treat it as root and the inner loop will do lever order traversal on this root. Now check the data of left and right child of root with root data and accordingly increment the length of BST traversed so far.Compare this length with a max value and accordingly update the max value. Finally return max value. Something like below. int len =0; int i=0; int size = l.size(); int tempLen =0; for(i=0;i q = new LinkedList(); q.add(i); tempLen =1; while(!q.isEmpty()){ int j = q.poll(); if(2*j+1 < size){ if(l.get(2*j+1).data= l.get(j).data){ tempLen++; q.add(2*j+2); } } } if(tempLen>len){ len = tempLen; } } return len; -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Data Structure for URL matching
What you may need is a reverse trie. You may take a look at this: > http://phpir.com/tries-and-wildcards On Aug 15, 3:21 pm, amit wrote: > In our indexes, we have millions of URLs each of which has a link to > some page contents, that is, URL->contents. Now, suppose a user types > a query with wild cards *, which represent 0 or multiple occurrences > of any characters, how do you build the indexes such that such a type > of query can be executed efficiently by finding all corresponding > URLs->contents efficiently. For example, given a queryhttp://www.*o*ve*ou.com. > > You need to find iloveyou.com, itveabcu.com, etc. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Alternative merge
In fact this solution was suggested (without code) in the original discussion. It's O(n^2). You're only re-ordering a constant number (4) of elements in each recursive pass, and each pass requires O(n) time to execute. You also need to assume your compiler will remove the tail recursion. Otherwise it will also require O(n) space, which misses the whole point of the problem. On Aug 15, 12:29 pm, Debajyoti Sarma wrote: > Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} > we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} > without using extra buffer space. > here a solution i came up withhttp://codepad.org/ub5Ie4sI > I know this was discussed before . > But i want to know the time complexity of the code i have given(i m > confused) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Delete vs Free
yup callin destructor ,, deallocate memory of resources allocated by object like heap memory of pointer ,, On Sun, Aug 15, 2010 at 3:58 PM, amit wrote: > I have read that Delete is more safer than free as Delete calls the > destructor of the object but i dont get whats the reason for calling > the destructor if anyways it want to deallocate the memory. > Does calling the destructor serves any other purpose?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Alternative merge
Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} without using extra buffer space. here a solution i came up with http://codepad.org/ub5Ie4sI I know this was discussed before . But i want to know the time complexity of the code i have given(i m confused) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Data Structure for URL matching
In our indexes, we have millions of URLs each of which has a link to some page contents, that is, URL->contents. Now, suppose a user types a query with wild cards *, which represent 0 or multiple occurrences of any characters, how do you build the indexes such that such a type of query can be executed efficiently by finding all corresponding URLs- >contents efficiently. For example, given a query http://www.*o*ve*ou.com. You need to find iloveyou.com, itveabcu.com, etc. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Delete vs Free
I have read that Delete is more safer than free as Delete calls the destructor of the object but i dont get whats the reason for calling the destructor if anyways it want to deallocate the memory. Does calling the destructor serves any other purpose?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Shuffling a deck of cards
Let X1, X2…. XN (In this case N=52) be the set of N numbers to be shuffled. 1. Set j to N 2. Generate a random number R. (uniformly distributed between 0 and 1) 3. Set k to (jR+1). k is now a random integer, between 1 and j. 4. Exchange Xk and Xj 5. Decrease j by 1. 6. If j > 1, return to step 2. void Shuffle(int* pArr) { int rand; for(int i=51;i>=0;i--) { rand=GenRand(0,i); swap(pArr[i], pArr[rand]); } } GenRand(int min, int max) generates a random number between min and max. On Sun, Aug 15, 2010 at 9:10 AM, Dave wrote: > @Sharad: Your code does not produce equally probable shuffles. You can > see this by noting that a[0] is swapped with one of 52 cards, same for > a[1], a[2], ..., a[51]. Thus, there are 52^52 possible sets of swaps. > But there are only 52! possible outcomes, and 52^52 / 52! is not an > integer. > > You can verify this experimentally by shuffling a small deck, say 3 > cards. If you do so, you will find that, starting with the deck ABC, > you get ABC 4/27 of the time, ACB 5/27, BAC 5/27, BCA 5/27, CAB 4/27, > and CBA 4/27. Thus, some outcomes are 25% more likely than others. > > The proper code is > for(i=1;i<52;++i) > { > int r=rand()%(i+1); > swap(a[i],a[r]); > } > > Dave > > On Aug 14, 9:34 pm, sharad kumar wrote: > > for(i=0;i<52;++i) > > { > > int r=rand()%52; > > swap(a[i],a[r]); > > > > } > > On Sat, Aug 14, 2010 at 11:46 PM, amit wrote: > > > write a program to shuffle an pack of cards in the most efficient way. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To post to this group, send email to algoge...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > algogeeks+unsubscr...@googlegroups.com > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/algogeeks?hl=en. > > > > -- > > yezhu malai vaasa venkataramana Govinda Govinda > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Rahul singhal RnD Engineer Tejas Networks Mobile- 09916969422 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Addition Of numbers in SLL
@Manjunath: A small snippet of my explanation of what? What do you not understand? Dave On Aug 15, 1:49 am, Manjunath Manohar wrote: > @Dave..Can u provide a small snippet for ur explanation pls.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.