[algogeeks] Re: Directi Written Q 2012

2012-07-30 Thread Zyro
int func(int start,int end) { int count=0; for(int i=start;i=end;i++) { int tmp=i; while(tmp!=0) { tmp=tmp(tmp-1); count++; } } return count; } Worst Case complexity : O((b-a)*32) Please let me know if there is another gud way to do

[algogeeks] Re: Write a C program to reconstruct a BST from a given array of preorder traversal.

2012-07-05 Thread Zyro
@Navin : Why r u sorting the array .. BST can be made using the preorder traversal if null nodes are well defined in the given traversal.. Right?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Write a C program to reconstruct a BST from a given array of preorder traversal.

2012-07-05 Thread Zyro
?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/HQ_TvoKSLNgJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

[algogeeks] Re: simple FILE reading problem.

2012-07-05 Thread Zyro
@Navin : Read a line .. store it in a string .. then extract numbers frm it.. It will be more faster i think.. :) On Wednesday, 4 July 2012 22:44:04 UTC+5:30, Navin Kumar wrote: Suppose a file.txt contains : 50 40 30 # # 5 # 10 # # i want to fetch only integers. How should i fetch it. I

[algogeeks] Re: Represent a number in base of minus 2 ????

2012-01-30 Thread Zyro
@Sharad.. Thanx.. :) On Jan 31, 2:42 am, sharad dixit sharad.emine...@gmail.com wrote: @zyro May be this solves your problem... #include iostream using namespace std; int main() {     int no;     char digit[50];     int counter=0;     cin no;     do

[algogeeks] Represent a number in base of minus 2 ????

2012-01-29 Thread Zyro
Write a function that takes an integer and returns a char array that contains the -2 (minus 2) base representation of the given integer. Example: Input Output 7 11011 3 111 2 110 Plzzz help ??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Re: Represent a number in base of minus 2 ????

2012-01-29 Thread Zyro
@Anika 7 = 1*((-2)^4) + 1*((-2)^3) + 0*((-2)^2) + 1*((-2)^1) + 1*((-2)^0) ... simlilary for other numbers... -- 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 unsubscribe

[algogeeks] Re: Problem

2011-11-19 Thread Zyro
along with its difference    b. add the difference of the newly added element. O(nlogn) On Nov 19, 11:36 am, Zyro vivkum...@gmail.com wrote: sorry...minimize sum of the difference between the elements of the subset.. On Nov 19, 10:03 am, shady sinv...@gmail.com wrote: what

[algogeeks] Problem

2011-11-18 Thread Zyro
Q: Select the K elements in an array of size N which are having the minimum difference among them? For Example : If you have an array like arr[]={9,5,2,6,3,11} and value of K is 3. Then ans would be {2,3,5}. -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] Re: Problem

2011-11-18 Thread Zyro
? On Nov 18, 6:30 pm, Zyro vivkum...@gmail.com wrote: Q: Select the K elements in an array of size N which are having the minimum difference among them? For Example : If you have an array like arr[]={9,5,2,6,3,11} and value of K is 3. Then ans would be {2,3,5}. -- You received

[algogeeks] Re: Problem

2011-11-18 Thread Zyro
. On Nov 19, 10:03 am, shady sinv...@gmail.com wrote: what do you mean by difference among them ? do we need to select the elements to minimize the sum between consecutive elements ? or only the first and last element ? On Nov 18, 6:30 pm, Zyro vivkum...@gmail.com wrote: Q: Select the K