Re: [algogeeks] What is the error in the following function
here start is pointing to string constant which is created in read-only memory which can't be changed.so modifying it in the for loop causes segmentation fault declare it as a array type On Tue, Feb 15, 2011 at 12:36 PM, rahul rahulr...@gmail.com wrote: char *start is const char *start, pointer to const char, u can't derefernce it and change it. take a char start[256].try this. On Tue, Feb 15, 2011 at 12:31 PM, dinesh bansal bansal...@gmail.comwrote: Hi All, Can you please point me to the error in the following function. It gives segmentation fault. int main() { char *start = 12.12.12.12.12976665176069214; char *hex_buf = 65003a0a; unsigned short i, j = 0; int new_len2 = strlen(hex_buf); for (i = 0; ((j+1) new_len2); i+=2,j+=2) { start[i] = hex_buf[j]; start[i+1] = hex_buf[j+1]; } } Thanks, -- Dinesh Bansal The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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] Invitation to Bytecode 2011
Hi all, I would like to invite you all to participate in Bytecode 2011, a 6-hour ACM ICPC style algorithm intensive online programming competition. Bytecode is organized as a part of Pragyan 2011, the International Level Techno-Managerial Festival of National Institute of Technology, Tiruchirappalli (NIT Trichy). Bytecode 2011 is scheduled to be held on the 20th of February 2011, Sunday, from 14:30 Hrs IST to 20:30 Hrs IST. You can check when the contest begins in your time zone here: http://www.timeanddate.com/worldclock/fixedtime.html?day=20month=2year=2011hour=14min=30sec=0p1=176 Registration for the contest is free and open to all. Participation can be in teams of utmost 3 members. Prizes worth INR 80,000 to be won. We promise you a really exciting and challenging set of problems! Hope to see you all @ Bytecode '11. For more details and rules and regulations, visit: http://www.codechef.com/BYTCDE11/ http://www.pragyan.org/11/home/events/encipher/bytecode/ For queries, mail to: bytec...@pragyan.org Looking forward to your participation in the contest. Problems and solutions to last year's Bytecode can be found here: http://www.pragyan.org/media/img/solutions.zip Topcoder link to previous year's Bytecode: http://forums.topcoder.com/?module=ThreadthreadID=666356start=0mc=3#1205512 Regards Thanks, P.Suhash (Manager - Bytecode) -- 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] SUDHIR MISHRA wants to chat
--- SUDHIR MISHRA wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-62d5befb93-3fceb99bf3-oYX-pec-NCYCzMLIBV7yRJ6EMUI You'll need to click this link to be able to chat with SUDHIR MISHRA. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with SUDHIR MISHRA, visit: http://mail.google.com/mail/a-62d5befb93-3fceb99bf3-oYX-pec-NCYCzMLIBV7yRJ6EMUI Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- 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] What is the error in the following function
got it clear.. thanks guys. On Tue, Feb 15, 2011 at 1:46 PM, jagannath prasad das jpdasi...@gmail.comwrote: here start is pointing to string constant which is created in read-only memory which can't be changed.so modifying it in the for loop causes segmentation fault declare it as a array type On Tue, Feb 15, 2011 at 12:36 PM, rahul rahulr...@gmail.com wrote: char *start is const char *start, pointer to const char, u can't derefernce it and change it. take a char start[256].try this. On Tue, Feb 15, 2011 at 12:31 PM, dinesh bansal bansal...@gmail.comwrote: Hi All, Can you please point me to the error in the following function. It gives segmentation fault. int main() { char *start = 12.12.12.12.12976665176069214; char *hex_buf = 65003a0a; unsigned short i, j = 0; int new_len2 = strlen(hex_buf); for (i = 0; ((j+1) new_len2); i+=2,j+=2) { start[i] = hex_buf[j]; start[i+1] = hex_buf[j+1]; } } Thanks, -- Dinesh Bansal The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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. -- Dinesh Bansal The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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] Call for Papers: The 2011 International Conference on Computer Graphics and Virtual Reality (CGVR'11), USA, July 18-21, 2011
CALL FOR PAPERS and Call For Workshop/Session Proposals CGVR'11 The 2011 International Conference on Computer Graphics and Virtual Reality Date and Location: July 18-21, 2011, USA http://www.world-academy-of-science.org/ Location: See the above web site for venue/city You are invited to submit a full paper for consideration. All accepted papers will be published in the CGVR conference proceedings (in printed book form; later, the proceedings will also be accessible online). Those interested in proposing workshops/sessions, should refer to the relevant sections that appear below. SCOPE: Topics of interest include, but are not limited to, the following: O Computer animation O Software tools for computer graphics O Rendering methods O Compression methods O Computational geometry O Fractal geometry and applications O Sound rendering technologies O Color and texture O Modeling techniques O Visualization O Surface modeling O Web 3D and applications O Machine architectures/engines for graphics and VR O Modeling of natural scenes and phenomena O Computer art and entertainment (including games) O Shadows, translucency and visibility O e-Learning applications and computer graphics O Illumination and reflection techniques O Interactive digital media O 3D reconstruction O Curves and meshes O Visual computing and graphics O Image data structures for computer graphics O Graphics algorithms and applications O Case studies and emerging technologies --- O Virtual environments O Virtual and augmented reality O Virtual humans and artificial life O Real-time collision detection algorithms O Immersive virtual reality O Virtual reality, visualization, and education O Interactive techniques O Learning and assessment based on virtual reality approaches O Virtual laboratories O Virtual reality tools/languages (X3D, Kinect, VRML, Java3D, OpenGL, ...) O Real-time rendering for VR O Emerging display technologies O Virtual reality techniques for behavioral and cognitive assessment O Simulation and virtual reality O Software tools for virtual reality O Human-computer interfaces O Multimodal display systems O Integration of virtual reality and multimedia O Haptic devices and techniques O Virtual reality and emerging applications USEFUL WEB LINKS: To see the DBLP list of accepted papers of CGVR 2009, go to: http://www.informatik.uni-trier.de/~ley/db/conf/cgvr/cgvr2009.html The DBLP list of accepted papers of CGVR 2010 will soon appear at: http://www.informatik.uni-trier.de/~ley/db/conf/cgvr/cgvr2010.html CGVR 2011 URL: http://www.world-academy-of-science.org/worldcomp11/ws/conferences/cgvr11 IMPORTANT DATES: March 10, 2011: Submission of papers (about 5 to 7 pages) April 03, 2011: Notification of acceptance (+/- two days) April 24, 2011: Final papers + Copyright/Consent + Registration July 18-21, 2011: The 2011 International Conference on Computer Graphics and Virtual Reality (CGVR'11) ACADEMIC CO-SPONSORS: Currently being prepared - The Academic sponsors of the last offering of CGVR (2010) included research labs and centers affiliated with (a partial list): University of California, Berkeley; University of Southern California; University of Texas at Austin; Harvard University, Cambridge, Massachusetts; Georgia Institute of Technology, Georgia; Emory University, Georgia; University of Minnesota; University of Iowa; University of North Dakota; NDSU-CIIT Green Computing Comm. Lab.; University of Siegen, Germany; UMIT, Austria; SECLAB (University of Naples Federico II + University of Naples Parthenope + Second University of Naples, Italy); National Institute for Health Research; World Academy of Biomedical Sciences and Technologies; Russian Academy of Sciences, Russia; International Society of Intelligent Biological Medicine (ISIBM); The International Council on Medical and Care Compunetics; Eastern Virginia Medical School the American College of Surgeons, USA. SUBMISSION OF PAPERS: Prospective authors are invited to submit their papers by uploading them to the evaluation web site at: http://world-comp.org Submissions must be uploaded by March 10, 2011 and they must be in either MS doc (but not docx) or pdf formats (about 5 to 7 pages - single space, font size of 10 to 12). All reasonable typesetting formats are acceptable (later, the authors of accepted papers will be asked to follow a particular typesetting format to prepare their final papers for publication.) Papers must not have been previously published or currently submitted for publication elsewhere. The first page of the paper should include: title of the paper, name, affiliation, postal address, and email address for each author. The first page should also identify the name of the Contact Author and a maximum
Re: [algogeeks] Re: SPOJ problem code:MAJOR
@Akshata I managed to get AC with majority algorithm. suggestions: 1) You can try to read input and find candidate in same loop 2) Use scanf and printf Thanks, Balaji. On Tue, Feb 15, 2011 at 4:30 PM, jai gupta sayhelloto...@gmail.com wrote: #includestdio.h #includestring.h #includemalloc.h void work() { int n,max,maxpos,x,i; scanf(%d,n); int *arr=(int*) malloc(sizeof(int)*2005); memset(arr,0,2005); max=maxpos=0; for(i=0;in;i++) { scanf(%d,x); arr[x+1000]++; if(arr[x+1000]max) { max=arr[x+1000]; maxpos=x; } } if(maxn/2) printf(YES %d\n,maxpos,max); else printf(NO\n); } int main() { int t; scanf(%d,t); while(t--) work(); 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. -- 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] Byte or Bite...Its byte Array
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.
[algogeeks] MS : Design an expensive clock for 4-7 year olds
the idea is to check how far the imagination can go Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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] question at K10
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.
[algogeeks] GOOG: Design a circular buffer and write the code for the reader and writer routines
as i see this would need synchronization... anyone tried it so far? Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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] Byte or Bite...Its byte Array
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] Re: question at K10
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.
Re: [algogeeks] Re: question at K10
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.
[algogeeks] Re: question at K10
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.
[algogeeks] Re: Help
Mike Johnson wrote: Plesae rite a program for me to find prime nummers. It should be recursive prorgram. What duz that mean? If u type a nummer like 10 it should say 1 is prime, 2 is prime, 3 is prime, 4 is not prime up to 10. This iz not homewurk I just thout of it myself. Lol. /* Sure Mike, Happy to help! This program implements a blindingly fast O(n^n) algorithm to find prime numbers, using an elegant recursive method. */ int _(int n, int m, int d, int t) { int r; if (t) return d?1+_(n,m,d-1,d):n?_(n-1,m,m,n):0; for(r=m!=n; d*(tn); ++t) r = _(n,_(t,m,0,1),d-1,0)|!_(t,1,t,0); return r*n; } /*-- Print primes up to the requested value */ int main(int argc, char* argv[]) { int max; scanf(%d, max); for(int n = 2; n = max; n++) printf(%d is%s prime\n,n, _(n,1,n,0)?: not); 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.
Re: [algogeeks] Re: question at K10
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.
[algogeeks] Invitation for Online programming competition DOPE
Hello, we like to invite you all to participate in Online Programming Contest organized as a part of Daksh 2011, an international level Technical festival of SASTRA University, Thanjavur, Tamilnadu We have two competitions: 1) DOPE Dope is a 6 hour ACM ICPC style algorithmic competition with team of size atmost 2. The contest will be held on 20th Feb, 2011 from 9.00 hrs IST (GMT +5:30); check your time zone http://www.timeanddate.com/worldclock/fixedtime.html?year=2011month=02day=20hour=3min=30sec=0p1=0 You can register your self to http://daksh.sastra.edu/online/online.php Practice on http://www.spoj.pl/DOPE/ 2) Code-Athlon It is c/c++ programming event which has first online round and then 2 onsite round first round problems will appear on event link on 15th Feb 2011 at 0.00 hrs IST (GMT +5:30) and last date of submission of answers will be till 18th Feb 2011, 23.59 hrs IST (GMT +5:30). you can register your team to http://daksh.sastra.edu/events.php#events/comp Thanks and Regards Team, Daksh 2011 -- 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
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.
Re: [algogeeks] Re: question at K10
nice solution -- 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
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.
Re: [algogeeks] GOOG: Design a circular buffer and write the code for the reader and writer routines
here is my approach. shared variables : in, out shared memory : buf[N] writer while(1) { while(in+1 % N ==out) { // waiting } buf[in+1]= input; in = in+1 % N } reader while(1) { while(out == in) { // waiting } output = buf[out] out = out+1 % N } On Tue, Feb 15, 2011 at 10:35 PM, Ashish Goel ashg...@gmail.com wrote: as i see this would need synchronization... anyone tried it so far? Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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. -- regards, chinna. -- 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: interview quest..
@Abhijit. Does your code takes O(N^2)? I think the following code would do it in O(N) iterate the string once: void remove(char *a){ if(!a){ int i = 0, j = 1; while(a[j]!='\0'){ if(i0 || a[i]!=a[j]){ if(j-1i){ a[i+1] = a[j]; } i++;j++; }else{ for(;a[j]==a[i];j++); i--; } } a[i+1] = '\0'; } } On Feb 14, 11:17 pm, Tushar Bindal tushicom...@gmail.com wrote: if we have RBGGGBGGBR what should be the answer??? RBGR or (empty string) On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami rajan.goswam...@gmail.comwrote: yeh. Agree with ramkumar. Simplest solution is to use Stack... On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao abhijitkrao...@gmail.comwrote: I could not get it for recursively, but iteratively, I coded a solution. If anyone knows recursively, let us know please. #includestdio.h void main() { char s[18]=DGGDBCBHH; int i=0,j=0; int count; while(s[i]!='\0') { if(s[i] == s[i+1]) { count = strlen(s)-2; while(count--) { s[i]=s[i + 2]; i++; } s[i]='\0'; i=0; } else { i++; } } printf(%s,s); getch(); } I/P: DGGDBCBHH O/P: BCB Best Regards Abhijit On Sun, Feb 6, 2011 at 1:47 PM, ramkumar santhanam ramkumars@gmail.com wrote: use stack. -- 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com -- 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: interview quest..
can any1 tell me the question .. m gettin half of the post ,... On Wed, Feb 16, 2011 at 10:41 AM, Jammy xujiayiy...@gmail.com wrote: @Abhijit. Does your code takes O(N^2)? I think the following code would do it in O(N) iterate the string once: void remove(char *a){ if(!a){ int i = 0, j = 1; while(a[j]!='\0'){ if(i0 || a[i]!=a[j]){ if(j-1i){ a[i+1] = a[j]; } i++;j++; }else{ for(;a[j]==a[i];j++); i--; } } a[i+1] = '\0'; } } On Feb 14, 11:17 pm, Tushar Bindal tushicom...@gmail.com wrote: if we have RBGGGBGGBR what should be the answer??? RBGR or (empty string) On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami rajan.goswam...@gmail.com wrote: yeh. Agree with ramkumar. Simplest solution is to use Stack... On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao abhijitkrao...@gmail.comwrote: I could not get it for recursively, but iteratively, I coded a solution. If anyone knows recursively, let us know please. #includestdio.h void main() { char s[18]=DGGDBCBHH; int i=0,j=0; int count; while(s[i]!='\0') { if(s[i] == s[i+1]) { count = strlen(s)-2; while(count--) { s[i]=s[i + 2]; i++; } s[i]='\0'; i=0; } else { i++; } } printf(%s,s); getch(); } I/P: DGGDBCBHH O/P: BCB Best Regards Abhijit On Sun, Feb 6, 2011 at 1:47 PM, ramkumar santhanam ramkumars@gmail.com wrote: use stack. -- 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com -- 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.
Re: [algogeeks] Re: interview quest..
stack for sure.. pop out the enteries till they r same and push this entry back once. On Wed, Feb 16, 2011 at 11:18 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: can any1 tell me the question .. m gettin half of the post ,... On Wed, Feb 16, 2011 at 10:41 AM, Jammy xujiayiy...@gmail.com wrote: @Abhijit. Does your code takes O(N^2)? I think the following code would do it in O(N) iterate the string once: void remove(char *a){ if(!a){ int i = 0, j = 1; while(a[j]!='\0'){ if(i0 || a[i]!=a[j]){ if(j-1i){ a[i+1] = a[j]; } i++;j++; }else{ for(;a[j]==a[i];j++); i--; } } a[i+1] = '\0'; } } On Feb 14, 11:17 pm, Tushar Bindal tushicom...@gmail.com wrote: if we have RBGGGBGGBR what should be the answer??? RBGR or (empty string) On Mon, Feb 7, 2011 at 3:51 PM, rajan goswami rajan.goswam...@gmail.comwrote: yeh. Agree with ramkumar. Simplest solution is to use Stack... On Sun, Feb 6, 2011 at 8:11 PM, Abhijit K Rao abhijitkrao...@gmail.comwrote: I could not get it for recursively, but iteratively, I coded a solution. If anyone knows recursively, let us know please. #includestdio.h void main() { char s[18]=DGGDBCBHH; int i=0,j=0; int count; while(s[i]!='\0') { if(s[i] == s[i+1]) { count = strlen(s)-2; while(count--) { s[i]=s[i + 2]; i++; } s[i]='\0'; i=0; } else { i++; } } printf(%s,s); getch(); } I/P: DGGDBCBHH O/P: BCB Best Regards Abhijit On Sun, Feb 6, 2011 at 1:47 PM, ramkumar santhanam ramkumars@gmail.com wrote: use stack. -- 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. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tusharbin...@jugadengg.com, tushicom...@gmail.com -- 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.
[algogeeks] Re: Binary Tree Amazon
hash would be a perfect choice. I make a MinMaxHash class which would keep track of the min and max value of the key.(since in this case we would never remove a key, thus this primitive approach works. Otherwise use treeMap) class MinMaxHash extends HashMap{ private Integer min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; @Override public Object put(Object key, Object value){ if((Integer)key min){ min = (Integer)key; } if((Integer)key max){ max = (Integer)key; } return super.put(key,value); } public Integer getMin(){return min;} public Integer getMax(){return max;} } The propagate(TNode t, int k, MinMaxHash res) would form a MinMaxHash-- res. public static void propagate(TNode t, int k, MinMaxHash res){ if(t == null){ return; }else{ if(res.containsKey(k)){ res.put(k,(Integer)res.get(k)+t.data); }else{ res.put(k, new Integer(t.data)); } propagate(t.left,k-1,res); propagate(t.right,k+1,res); } } The ArrayListInteger findVertical(TNode root) would return a ArrayList containing the result. The idea is to form a MinMaxHash for left subtree and right subtree. And test a few cases for the root and the line number for the right subtree. The code should be pretty self-explanatory. (TNode has int data, TNode left and TNode right)excuse me for the poor writings of java code, I suck at writing beautiful java code like others in this group do.. public static ArrayListInteger findVertical(TNode root){ ArrayListInteger res = new ArrayListInteger(); MinMaxHash left = new MinMaxHash(); MinMaxHash right = new MinMaxHash(); propagate(root.left,0,left); propagate(root.right,0,right); if(left.size()0){ for(int i = left.getMin(); i = left.getMax(); i++){ res.add((Integer)left.get(i)); } } if(left.getMax()==0 || left.size() ==0){ res.add(root.data); }else{ res.set(res.size()-1, (Integer)res.get(res.size()-1)+root.data); } if(right.size()0){ int start = right.getMin(); if(start 0){ res.set(res.size()-1,(Integer)res.get(res.size()-1)+ (Integer)right.get(start)); start++; } for(int i = start; i = right.getMax(); i++){ res.add((Integer)right.get(i)); } } return res; } On Feb 14, 9:11 am, sankalp srivastava richi.sankalp1...@gmail.com wrote: Just a slight addition , you would also like to keep a record for the maximum range of the levels (assuming the function is called as (root , 0)) On Feb 14, 5:25 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: use hash take an array verticalsum[]={0}; the function will be like this void vertcal_sum(node *root, int level){ if(root!=NULL){ verticalsum[level]+=root-data; vertcal_sum(root-left,level-1); vertcal_sum(root-left,level+1); } } On Mon, Feb 14, 2011 at 5:04 PM, bittu shashank7andr...@gmail.com wrote: Given a binary tree with no size limitation, write a program to find the sum of each vertical level and store the result in an appropriate data structure (Note: You cannot use an array as the tree can be of any size). 4 / \ 7 8 / \ / \ 10 11 / 13 12 here 4(root) , 11(leftsubtree's right child ), 12 (rightsubtree's left child) are in same vertical Line so here vertical line 1 is fro 10 vertical line 2 sum is 7 vertical line 3 sum is 4+11+12=27 (May Have Some Doubt So i Have represented the figure in correct way) vertical line 4 is 8 vertical line 5 is 13 Hope its clear to every one 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. -- 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