×

is there some sort of memory limit in the solutions we submit..is it okay to use unsigned long long arr[10^7] or does it give sigsegv??

 0 i have this code for TSORT...it works fine on my computer but gives run time error SIGSEGV ..pls have a look at it and tell me whats the bug...thanks... #include void partition(unsigned long long arr[],unsigned long long first,unsigned long last); void m_sort(unsigned long long arr[],unsigned long long low,unsigned long long mid,unsigned long long high); int main(void) { unsigned long long t,n,i=0; unsigned long long arr[10^7]; scanf("%llu",&n); t=n; //accepting elements while(t--) { scanf("%llu",&arr[i++]); } partition(arr,0,n-1); for(i=0;imid) { while(m<=high) { temp[k++]=arr[m++]; } } else { while(i<=mid) { temp[k++]=arr[i++]; } } for(i=low;i<=high;i++) { arr[i]=temp[i]; } }  asked 18 Dec '13, 20:04 31●2●4●6 accept rate: 0%

 3 Use global declaration for big array size. In main function it will cause stack overflow. answered 18 Dec '13, 22:15 4★abbas 411●8 accept rate: 28% also write '10000000' not 10^7. '^' is bitwise xor opertion. (18 Dec '13, 22:16) abbas4★ 1 There is simply not that much memory on the stack. There is much more memory available on the heap so you can either allocate the array on the heap or globally :) (19 Dec '13, 00:44) password1★ @abbas tried global declaration..it still gives SIGSEGV and @password...10^7 works...i have tried it in other programs and got AC (19 Dec '13, 11:39)
 0 ^ is Bitwise XOR operator in C/C++. Therefore 10^7 = 13 so 10^7 will only allocate an array of size 13. If you are not convinced, you can try printf("%d\n",10^7); answered 19 Dec '13, 17:32 5★n2n_ 1.8k●6●13●19 accept rate: 9% @n2n_..i tried replacing the 10^7 in the array declarations to 10000000 but it is still giving SIGSEGV..any idea why (19 Dec '13, 20:26) Did you make the array a global variable? (19 Dec '13, 20:35)
 0 generally the maximum array size you can declare is int array of 4*10^6 for most of the problems..And declare it globally.10^7,generally,that much memory is not provided. answered 19 Dec '13, 22:18 358●4●8●15 accept rate: 0% @orchidmajumder ..thanks it worked.. (19 Dec '13, 22:27) @orchidmajumder..can you tell me what the error is in the PCYCLE..question in the forum...it also has SIGSEGV (19 Dec '13, 22:40)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×280
×38

question asked: 18 Dec '13, 20:04

question was seen: 2,918 times

last updated: 19 Dec '13, 22:40