Re: [algogeeks] Re: question at K10
and also void change() { // Code here int x = 1; int*p= x; while(*p != 5) p++; *p = 10; } On Wed, Feb 16, 2011 at 8:02 AM, Balaji S balaji.ceg...@gmail.com wrote: The solution is.. _AX = 10; can anyone explain?? -- 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 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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 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: question at K10
a one line solution is needed... -- 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 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] API Question Adobe
one system API available setOStimer(time n, function ptr, function arg) it sets time for n sec. after expiration of timer it calls function. if another timer set with setOStimer, it will erase previously sets timer. Ex. at t = 0, setOStimer(5,fn,arg) at t = 4, setOStimer(10,fn1,arg1) now first timer removed. Question is using this API, write own API setTimer(), it will use given API. So that it will not erase previously set timer. Thanks Shashank -- 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 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] General Sorting Header File Adobe
write header file for sorting general element. it can sort any type of object(int,float,complex number, objects) Thanks Shashank -- 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 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] Application Data Structure In Collision Detection
many irregular shape objects are moving in random direction. provide data structure and algo to detect collision. Remember that objects are in million. Thanks Shashank -- 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 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] Maths
please help.. if f(n+1) = max{ f(k) + f(n-k+1) + 1} for 1 = k = n; f(1) = 0. Find f(n+1) in terms of n. Eg: f(4) = ? n = 3; 1= k = 3; f(4) = max{f(1) + f(3) + 1, f(2) + f(2)+1, f(3) + f(1) +1} -- 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 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: General Sorting Header File Adobe
templateclass Iterator, class Compare void sort(Iterator first, Iterator last, Compare cmp); On Feb 16, 5:57 am, bittu shashank7andr...@gmail.com wrote: write header file for sorting general element. it can sort any type of object(int,float,complex number, objects) Thanks Shashank -- 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 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] Maths
f(n)=n-1. On Wed, Feb 16, 2011 at 7:39 PM, Akshata Sharma akshatasharm...@gmail.comwrote: please help.. if f(n+1) = max{ f(k) + f(n-k+1) + 1} for 1 = k = n; f(1) = 0. Find f(n+1) in terms of n. Eg: f(4) = ? n = 3; 1= k = 3; f(4) = max{f(1) + f(3) + 1, f(2) + f(2)+1, f(3) + f(1) +1} -- 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 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 algogeeks@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: Maths
he first few f(i): f(1)=0 f(2)=max(f(1)+f(1-1+1)+1) = 1 f(3)=max{f(1)+f(2)+1, f(2)+f(1)+1} = 2 f(4)=max{f(1)+f(3)+1, f(2)+f(2)+1, f(3)+f(1)+1} =3 f(5)=max{f(1)+f(4)+1, f(2)+f(3)+1, ,f(4)+f(1)+1} = 4 f(6)=max{.} =5 what I can see here is in each f(i), all comma separated expressions evaluate to the same value. For exampe in f(5), all f(1)+f(4)+1, f(2)+f(3)+1evaluate to same value 4. so by inspection it is easy to see that the answer is: f(n+1) = n, for all n. This can be generalized on the base case to: f(n+1) = (n+1)*f(1) + n. But, how to go to prove such a thing formally? On Feb 16, 8:45 pm, Vikas Kumar dev.vika...@gmail.com wrote: f(n)=n-1. On Wed, Feb 16, 2011 at 7:39 PM, Akshata Sharma akshatasharm...@gmail.comwrote: please help.. if f(n+1) = max{ f(k) + f(n-k+1) + 1} for 1 = k = n; f(1) = 0. Find f(n+1) in terms of n. Eg: f(4) = ? n = 3; 1= k = 3; f(4) = max{f(1) + f(3) + 1, f(2) + f(2)+1, f(3) + f(1) +1} -- 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 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 algogeeks@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: Byte or Bite...Its byte Array
since it is guaranteed that l points to the start of the character. Thus I would refer to 'X‘ as the byte l points to. Each number in the following represents the MSB of the corresponding byte. E.g. 101X -- the byte preceding X has MSB 1 and the byte preceding that has MSB 0 the byte preceding that has MSB 1. The k-th character refers to the k- th character to the left of X. Now let's consider the following situation, where 1X Since X is the start of a character, thus the preceding byte couldn't the first byte of the 2-byte character albeit the MSB is 1. Thus we delete 1 byte preceding X. For the situation ***0X where the preceding byte MSB 0 we want to know if it is the start of a 1-byte character or the second byte of a 2-byte character. Thus we need to look back further. For 00X, we delete 1 byte since the 2nd byte has MSB 0, which means it either the second byte or the 1-byte character, either way, the 1st byte stands alone. For 010X, we delete 2. Similar logic. For 0110X, we delete one. Continue doing in the similar fashion, we conclude that if the 1st byte has MSB 0, count the number of 1s between that byte and the first byte to its left that has MSB 0 or we reach the very first byte of array. If the number of 1s is even, (including 0), delete 1 character preceding X and 2 otherwise. On Feb 15, 12:11 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: give an example as what to do .. tha language of the question is not clear to me On Tue, Feb 15, 2011 at 5:32 PM, bittu shashank7andr...@gmail.com wrote: Given a byte array, in which characters can be 1 byte or 2 bytes long For 1-byte characters, the Most significant bit must be 0. For a 2- byte character, the most significant bit of the most significant byte must be one and the most significant bit of the least significant byte is don’t care (X). You are given the index, I of a character in the byte array. Note that I-1 or I+1 can lead you to either a character or the middle of a character. Give a logic (no need of code) to delete the previous character of the one to which I points. Please Read The Question Carefully..Mean While I am Also think for Solution Thanks Regards Shashank -- 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 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. -- With Regards, *Jalaj Jaiswal* (+919019947895) Software developer, Cisco Systems B.Tech 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 algogeeks@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] Application of Data Structure
Given a set of words one after another, give a data structure so that you,will know whether a word has appeared already or not. Thanks Shashank -- 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 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] Application of Data Structure
Hash, SortedSet On Wed, Feb 16, 2011 at 9:58 PM, bittu shashank7andr...@gmail.com wrote: Given a set of words one after another, give a data structure so that you,will know whether a word has appeared already or not. Thanks Shashank -- 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 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 algogeeks@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] Application of Data Structure
build a tree On Wed, Feb 16, 2011 at 10:10 PM, vaibhav agrawal agrvaib...@gmail.com wrote: Hash, SortedSet On Wed, Feb 16, 2011 at 9:58 PM, bittu shashank7andr...@gmail.com wrote: Given a set of words one after another, give a data structure so that you,will know whether a word has appeared already or not. Thanks Shashank -- 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 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 algogeeks@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 algogeeks@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] Application of Data Structure
trie construction would do for this On Wed, Feb 16, 2011 at 10:15 PM, yv paramesh yv.param...@gmail.com wrote: build a tree On Wed, Feb 16, 2011 at 10:10 PM, vaibhav agrawal agrvaib...@gmail.com wrote: Hash, SortedSet On Wed, Feb 16, 2011 at 9:58 PM, bittu shashank7andr...@gmail.com wrote: Given a set of words one after another, give a data structure so that you,will know whether a word has appeared already or not. Thanks Shashank -- 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 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 algogeeks@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 algogeeks@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 algogeeks@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: question at K10
AX is the low order accumulator register used in the microprocessor generally the value returned is from the accumulator if u modify that value it will return the value u set it to as the Register is Divided into 2 parts AH - higher order and AX - lower order the value 10 is stored in AX and is returned On Feb 16, 7:32 am, Balaji S balaji.ceg...@gmail.com wrote: The solution is.. _AX = 10; can anyone explain?? -- 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 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: question at K10
nice solution On Feb 15, 11:22 pm, jagannath prasad das jpdasi...@gmail.com wrote: void change() { #define i i=10,n} this will do.. On Tue, Feb 15, 2011 at 11:33 PM, Rel Guzman Apaza rgap...@gmail.comwrote: Nothing... 10 in base 5 = 5 in base 10. void change(){ printf(); //...? } 2011/2/15 Don dondod...@gmail.com A semicolon is valid in the middle of a line in C or C++. For instance, no one says that for(i = 0; i 10; ++i) is three lines of code. Don On Feb 15, 11:31 am, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: after termination of semicolon , that will be considered a separate line i guess On Tue, Feb 15, 2011 at 10:59 PM, Don dondod...@gmail.com wrote: void change() { printf(10); while(1) {} } On Feb 15, 10:17 am, Balaji S balaji.ceg...@gmail.com wrote: Insert only one line in the function change() so that the output of the program is 10. You are not allowed to use exit(). You are not allowed to edit the function main() or to pass the parameter to change() void change() { // Code here} int main() { int i=5; change(); printf(“%d” ,i); return 0; } -- 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 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. -- With Regards, *Jalaj Jaiswal* (+919019947895) Software developer, Cisco Systems B.Tech 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 algogeeks@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 algogeeks@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 algogeeks@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: Byte or Bite...Its byte Array
case 1. |-|--| | 0 | remaining 7 bit| |-|--| MSB When Character is represented by 1 Byte case 2. ||-||-| | 1 | last 7 bit | dont care | last 7 bit of 2nd Byte | ||-||-| MSB of 1st MSB of 2nd Byte First Byte Second Byte When Character is represented by 1 Byte Thanks Regards Shashank -- 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 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] Puzzle For Puzzled Minds - Robots
Two robots are placed at different points on a straight line of infinite length. When they are first placed down, they each spray out some oil to mark their starting points. You must program each robot to ensure that the robots will eventually crash into each other. A program can consist of the following four instructions: * Go left one space * Go right one space * Skip the next instruction if there is oil in my current spot * Go to a label [Note that a label is a name that refers to a line of your code. For example, you could label the third line of your program surveying. Then, the instruction goto surveying would jump to line 3 and start executing from there on the next cycle.] A robot will carry out one instruction per second. Both robots need not have the same program. Note that you won't know ahead of time which robot is on the left and which is on the right. Thanks Regards Shashank Mani -- 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 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: Application of Data Structure
@all well i appreciate your suggestion but all of you replied one word answer actually i forget to say Best Data Structure why well hashing,trie will definitely solve this @ankit i wants to see your trie implementation for this problem , as i had not done lot stuff with trie (i read it theoretically) @vaibhav SortedSet seems to be odd Here isn't it.. Correct me if i am wrong Thanks Regards Shashank Mani -- 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 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: question at K10
Nice solution. Similarly you could #define: void change() { #define change() i=10 } On Feb 16, 12:55 pm, ankit sablok ankit4...@gmail.com wrote: nice solution On Feb 15, 11:22 pm, jagannath prasad das jpdasi...@gmail.com wrote: void change() { #define i i=10,n} this will do.. On Tue, Feb 15, 2011 at 11:33 PM, Rel Guzman Apaza rgap...@gmail.comwrote: Nothing... 10 in base 5 = 5 in base 10. void change(){ printf(); //...? } 2011/2/15 Don dondod...@gmail.com A semicolon is valid in the middle of a line in C or C++. For instance, no one says that for(i = 0; i 10; ++i) is three lines of code. Don On Feb 15, 11:31 am, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: after termination of semicolon , that will be considered a separate line i guess On Tue, Feb 15, 2011 at 10:59 PM, Don dondod...@gmail.com wrote: void change() { printf(10); while(1) {} } On Feb 15, 10:17 am, Balaji S balaji.ceg...@gmail.com wrote: Insert only one line in the function change() so that the output of the program is 10. You are not allowed to use exit(). You are not allowed to edit the function main() or to pass the parameter to change() void change() { // Code here} int main() { int i=5; change(); printf(“%d” ,i); return 0; } -- 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 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. -- With Regards, *Jalaj Jaiswal* (+919019947895) Software developer, Cisco Systems B.Tech 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 algogeeks@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 algogeeks@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 algogeeks@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: Application Data Structure In Collision Detection
one idea is that quad trees are used in 2d collision detection (and OctTrees in 3d collision detection). I haven't ever written a code on it but the basic premise is that every node represents a point and say has it's x and y co-ordinates and 4 children, which actually represent 4 quadrants. So if say your point is P, then if P.X root.X then point is either in upper left or lower left quadrant from root. Again if P.Y root.Y then point is in upper left quadrant. So you can recurse on root.uLeftPtr. Again please correct me if I am wrong. This is based on the limited idea I have on this topic Thanks Regards Shashank Mani The best way to escape from a problem is to solve it. -- 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 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: Puzzle For Puzzled Minds - Robots
On Feb 16, 12:53 pm, bittu shashank7andr...@gmail.com wrote: Two robots are placed at different points on a straight line of infinite length. When they are first placed down, they each spray out some oil to mark their starting points. You must program each robot to ensure that the robots will eventually crash into each other. A program can consist of the following four instructions: * Go left one space * Go right one space * Skip the next instruction if there is oil in my current spot * Go to a label [Note that a label is a name that refers to a line of your code. For example, you could label the third line of your program surveying. Then, the instruction goto surveying would jump to line 3 and start executing from there on the next cycle.] A robot will carry out one instruction per second. Both robots need not have the same program. Note that you won't know ahead of time which robot is on the left and which is on the right. Thanks Regards Shashank Mani RIGHT // Move off the starting spot Search: RIGHT // Move at speed of 1 space every third turn until you find the other robot's starting spot SKIP NEXT INSTRUCTION IF OIL GOTO Search Fast: RIGHT // Move at speed of 1 space every other turn GOTO Fast Both robots will move to the right, but the one on the left will eventually find the oil left by the other robot and begin moving faster, eventually catching up with the other robot. Don -- 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 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] UVa - Gold Coins
It seems to be a very easy problem, but I'm not finding an *equation *that solves it... could someone help me with the steps? Brief: A king pays 1 gold coin to a knight on the first day. 2 gold coins for the next 2 days, 3 gold coins for the next 3 days, and so on... Given a day N, how much gold coins the knight must receive? Link: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3045 Thank you all! :-) -- 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 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] UVa - Gold Coins
Let f(n) = n(n+1)/2 We have to find n1 and n2 such that f(n1) N = f(n2) and n2 = n1 + 1. Solution is n2. Can be done in O(1) as follows: Solve N = n(n+1)/2 for unknown n. Requires us to solve quadratic equation: n^2 + n - 2N = 0 Find positive root of the equation which could be a real number. n2 = ceil(n). On Wed, Feb 16, 2011 at 5:14 PM, Pedro Rezende web...@gmail.com wrote: It seems to be a very easy problem, but I'm not finding an *equation *that solves it... could someone help me with the steps? Brief: A king pays 1 gold coin to a knight on the first day. 2 gold coins for the next 2 days, 3 gold coins for the next 3 days, and so on... Given a day N, how much gold coins the knight must receive? Link: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3045 Thank you all! :-) -- 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 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 algogeeks@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] Large File Millions of Records
given a very large file (millions of record), find the 10 largest numbers from it.in minimum time complexity Don't think about hashing . Again Its Flat File Not the Database Thanks Regards Shashank Mani -- 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 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] String Operation
Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- 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 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] UVa - Gold Coins
I did it. #include iostream #include cmath using namespace std; int main(){ int n,ac,k,sum; while(cinn n){ ac=0; k=ceil((sqrt(1+8*n)-1)/2)-1; ac+=k*(k+1)*(2*k+1)/6; sum=(k+1)*(k+2)/2; ac+=(k+1)*((k+1)-(sum-n)); coutn acendl; } } 2011/2/16 nphard nphard nphard.nph...@gmail.com Let f(n) = n(n+1)/2 We have to find n1 and n2 such that f(n1) N = f(n2) and n2 = n1 + 1. Solution is n2. Can be done in O(1) as follows: Solve N = n(n+1)/2 for unknown n. Requires us to solve quadratic equation: n^2 + n - 2N = 0 Find positive root of the equation which could be a real number. n2 = ceil(n). On Wed, Feb 16, 2011 at 5:14 PM, Pedro Rezende web...@gmail.com wrote: It seems to be a very easy problem, but I'm not finding an *equation *that solves it... could someone help me with the steps? Brief: A king pays 1 gold coin to a knight on the first day. 2 gold coins for the next 2 days, 3 gold coins for the next 3 days, and so on... Given a day N, how much gold coins the knight must receive? Link: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3045 Thank you all! :-) -- 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 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 algogeeks@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 algogeeks@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] Program System Memory checking
WAP or Algo That will check whether the memory allotted to the program at the initial and the memory returned to the system is same or not. Thanks Regards Shashank Mani -- 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 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] Linked List Amazon
Given a linked list structure where every node represents a linked list and contains two pointers of its type: (i) pointer to next node in the main list. (ii) pointer to a linked list where this node is head. Write a C function to flatten the list into a single linked list. Eg. If the given linked list is 1 -- 5 -- 7 -- 10 | | | 2 6 8 | | 3 9 | 4 then convert it to 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 Thanks Regards Shashank Mani -- 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 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: General Sorting Header File Adobe
hope it may work typedef void (*Swapfunc)(void *element_1, void *element_2); typedef int (*Cmpfunc)(void *element_1, void *element_2); void GenericSort(void *array, uint32_t nbElems, Swapfunc swapFunc, Cmpfunc cmpFunc); Thanks Regards Shashank Mani The best way to escape from a problem is to solve it. -- 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 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: String Operation
Try this code. #includeiostream #includestring using namespace std; int main() { string sArray[5] ={aab,abc,bba,acc,bcc}; int n = 5; for(int i = 0;i n; i++) { for( int j = 0; j n - 1 ; j++) { if(sArray[j] sArray[j+1]) { string temp = sArray[j]; sArray[j] = sArray[j + 1]; sArray[j+1]= temp; } } } string sTemp; for(int k = 0; k n ;k++) { sTemp = sTemp + sArray[k]; } coutprinting result:: sTempendl; } n = Number of strings. On Feb 17, 9:56 am, bittu shashank7andr...@gmail.com wrote: Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- 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 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] UVa - Gold Coins
Hi All total number of coins = 1+(2+2)+(3+3+3)+(4+4+4+4)+(N+N+.N times) = 1+(2*2)+(3*3)+4*4+...+(N*N) = (N*(N+1)*(2N+1))/6 Please do correct me if i am wrong Regards Praveen On Thu, Feb 17, 2011 at 6:26 AM, Rel Guzman Apaza rgap...@gmail.com wrote: I did it. #include iostream #include cmath using namespace std; int main(){ int n,ac,k,sum; while(cinn n){ ac=0; k=ceil((sqrt(1+8*n)-1)/2)-1; ac+=k*(k+1)*(2*k+1)/6; sum=(k+1)*(k+2)/2; ac+=(k+1)*((k+1)-(sum-n)); coutn acendl; } } 2011/2/16 nphard nphard nphard.nph...@gmail.com Let f(n) = n(n+1)/2 We have to find n1 and n2 such that f(n1) N = f(n2) and n2 = n1 + 1. Solution is n2. Can be done in O(1) as follows: Solve N = n(n+1)/2 for unknown n. Requires us to solve quadratic equation: n^2 + n - 2N = 0 Find positive root of the equation which could be a real number. n2 = ceil(n). On Wed, Feb 16, 2011 at 5:14 PM, Pedro Rezende web...@gmail.com wrote: It seems to be a very easy problem, but I'm not finding an *equation *that solves it... could someone help me with the steps? Brief: A king pays 1 gold coin to a knight on the first day. 2 gold coins for the next 2 days, 3 gold coins for the next 3 days, and so on... Given a day N, how much gold coins the knight must receive? Link: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3045 Thank you all! :-) -- 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 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 algogeeks@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 algogeeks@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. -- B. Praveen -- 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 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: General Sorting Header File Adobe
@Bittu: It is interesting that you might want to sort complex numbers, since they don't form an ordered field. See, e.g., http://en.wikipedia.org/wiki/Ordered_field for an explanation why. Dave On Feb 16, 5:57 am, bittu shashank7andr...@gmail.com wrote: write header file for sorting general element. it can sort any type of object(int,float,complex number, objects) Thanks Shashank -- 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 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: String Operation
Greedy, always choose the remaining one that is the lexicographically smallest since choose any other way will yield a lexicographically greater one. void concante(char **strings, int n){ qsort(strings,n,sizeof(char *),compareStr); } int compareStr(const void *a, const void *b){ return strcmp(*(char **)a,*(char **)b); } On Feb 16, 10:05 pm, simplyamey kulkarniamey2...@gmail.com wrote: Try this code. #includeiostream #includestring using namespace std; int main() { string sArray[5] ={aab,abc,bba,acc,bcc}; int n = 5; for(int i = 0;i n; i++) { for( int j = 0; j n - 1 ; j++) { if(sArray[j] sArray[j+1]) { string temp = sArray[j]; sArray[j] = sArray[j + 1]; sArray[j+1]= temp; } } } string sTemp; for(int k = 0; k n ;k++) { sTemp = sTemp + sArray[k];} coutprinting result:: sTempendl; } n = Number of strings. On Feb 17, 9:56 am, bittu shashank7andr...@gmail.com wrote: Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- 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 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] Linked List Amazon
Node *flatten(Node *node) { if (!node) return NULL; Node *head = node; Node *next = node-next; node-next = NULL; if (node-down) node-next = flatten(node-down); while (node-next != NULL) node = node-next; node-next = flatten(next); return head; } On Wed, Feb 16, 2011 at 8:38 PM, bittu shashank7andr...@gmail.com wrote: Given a linked list structure where every node represents a linked list and contains two pointers of its type: (i) pointer to next node in the main list. (ii) pointer to a linked list where this node is head. Write a C function to flatten the list into a single linked list. Eg. If the given linked list is 1 -- 5 -- 7 -- 10 | | | 2 6 8 | | 3 9 | 4 then convert it to 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 Thanks Regards Shashank Mani -- 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 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 algogeeks@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: Large File Millions of Records
Divide records into parts that could fit into main memory. Do rank find algorithm for certain range if necessary. On Feb 16, 7:26 pm, bittu shashank7andr...@gmail.com wrote: given a very large file (millions of record), find the 10 largest numbers from it.in minimum time complexity Don't think about hashing . Again Its Flat File Not the Database Thanks Regards Shashank Mani -- 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 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] UVa - Gold Coins
Question is to find the number of coins received on Nth day and not the total number of coins received after N iterations. On Wed, Feb 16, 2011 at 11:48 PM, Praveen praveen200...@gmail.com wrote: Hi All total number of coins = 1+(2+2)+(3+3+3)+(4+4+4+4)+(N+N+.N times) = 1+(2*2)+(3*3)+4*4+...+(N*N) = (N*(N+1)*(2N+1))/6 Please do correct me if i am wrong Regards Praveen On Thu, Feb 17, 2011 at 6:26 AM, Rel Guzman Apaza rgap...@gmail.comwrote: I did it. #include iostream #include cmath using namespace std; int main(){ int n,ac,k,sum; while(cinn n){ ac=0; k=ceil((sqrt(1+8*n)-1)/2)-1; ac+=k*(k+1)*(2*k+1)/6; sum=(k+1)*(k+2)/2; ac+=(k+1)*((k+1)-(sum-n)); coutn acendl; } } 2011/2/16 nphard nphard nphard.nph...@gmail.com Let f(n) = n(n+1)/2 We have to find n1 and n2 such that f(n1) N = f(n2) and n2 = n1 + 1. Solution is n2. Can be done in O(1) as follows: Solve N = n(n+1)/2 for unknown n. Requires us to solve quadratic equation: n^2 + n - 2N = 0 Find positive root of the equation which could be a real number. n2 = ceil(n). On Wed, Feb 16, 2011 at 5:14 PM, Pedro Rezende web...@gmail.comwrote: It seems to be a very easy problem, but I'm not finding an *equation *that solves it... could someone help me with the steps? Brief: A king pays 1 gold coin to a knight on the first day. 2 gold coins for the next 2 days, 3 gold coins for the next 3 days, and so on... Given a day N, how much gold coins the knight must receive? Link: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3045 Thank you all! :-) -- 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 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 algogeeks@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 algogeeks@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. -- B. Praveen -- 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 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 algogeeks@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: Large File Millions of Records
take an array of 10 ,travese the whole rcord and apply min heap on these 10 elements. as like first 10 no will be there and we apply minheap so we will get minimun num in these 10 number..If next numbe is greater then minimun no in array ..we will replace it and apply minheap ... On Thu, Feb 17, 2011 at 11:12 AM, Jammy xujiayiy...@gmail.com wrote: Divide records into parts that could fit into main memory. Do rank find algorithm for certain range if necessary. On Feb 16, 7:26 pm, bittu shashank7andr...@gmail.com wrote: given a very large file (millions of record), find the 10 largest numbers from it.in minimum time complexity Don't think about hashing . Again Its Flat File Not the Database Thanks Regards Shashank Mani -- 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 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 algogeeks@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: String Operation
trie tree will be better to implement On Thu, Feb 17, 2011 at 11:07 AM, Jammy xujiayiy...@gmail.com wrote: Greedy, always choose the remaining one that is the lexicographically smallest since choose any other way will yield a lexicographically greater one. void concante(char **strings, int n){ qsort(strings,n,sizeof(char *),compareStr); } int compareStr(const void *a, const void *b){ return strcmp(*(char **)a,*(char **)b); } On Feb 16, 10:05 pm, simplyamey kulkarniamey2...@gmail.com wrote: Try this code. #includeiostream #includestring using namespace std; int main() { string sArray[5] ={aab,abc,bba,acc,bcc}; int n = 5; for(int i = 0;i n; i++) { for( int j = 0; j n - 1 ; j++) { if(sArray[j] sArray[j+1]) { string temp = sArray[j]; sArray[j] = sArray[j + 1]; sArray[j+1]= temp; } } } string sTemp; for(int k = 0; k n ;k++) { sTemp = sTemp + sArray[k];} coutprinting result:: sTempendl; } n = Number of strings. On Feb 17, 9:56 am, bittu shashank7andr...@gmail.com wrote: Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- 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 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 algogeeks@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] Find duplicate element in an array
since the question does not talk about extra space, make a BST but that will be nlgn.. or use counting sort for O(n) Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sun, Jan 16, 2011 at 8:51 AM, nphard nphard nphard.nph...@gmail.comwrote: Given an array of integers of size 'n' - consisting of 'n-2' unique integers and 1 integer with a duplicate, find the repeated element in O(n). Note: This is a converse of finding the unique element in an array consisting of duplicates - which can be solved with the XOR technique - but I am not sure if the same/similar technique can be applied here. -- 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 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 algogeeks@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.