O(n^2) algo is trivial. Can anybody think of a better approach ???
--
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
I don't think so. Try it on {2, 5, 1, 7} and {5, 7, 1, 2}
--
On Wed, Jul 27, 2011 at 10:33 AM, Sonal Maheshwari sonal...@gmail.comwrote:
i think the following shud work:
i=j=0;
while(i n jn) // n is the number of elements in the array
{
if ( a[i] b[j] )
{
Hey ankit, i gave java code also...didn't u check it in the link...anyway i
am explaining here.
*Note : Position count starts from 0. *
*ex: {1,2,3,4} ...position of '1' is zero*
*
*
*In the below approach,we are checking element position in the modified
list(after deletion
@shiva viknesh
this is a different Question...
@saurabh
how is nlgn possible, total no of possible substrings are n^2
this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh singh
for(int l = 0; l len; l++){
for(int i = 0; i len-l; i++){
Function to display the directory structure in a user friendly way taking
root dir as arg
for a general OS. You may assume and state some basic APIs available in that
OS
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
anyone??
On Tue, Jul 26, 2011 at 11:36 PM, geek forgeek geekhori...@gmail.comwrote:
Function to display the directory structure in a user friendly way taking
root dir as arg
for a general OS. You may assume and state some basic APIs available in
that OS
--
You received this message
Best case : O(n)
Worst case : O(n^2)
can be done using stack.
Thinking of better solution. .
On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal ankitsamb...@gmail.comwrote:
O(n^2) algo is trivial. Can anybody think of a better approach ???
--
You received this message because you are
Even in array best case can be O(n). Why use stack?
On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza
vishwakarma.ii...@gmail.com wrote:
Best case : O(n)
Worst case : O(n^2)
can be done using stack.
Thinking of better solution. .
On Wed, Jul 27, 2011 at 11:50 AM, ankit sambyal
i m suggesting stack not just for best case only .
On Wed, Jul 27, 2011 at 12:16 PM, Pankaj jatka.oppimi...@gmail.com wrote:
Even in array best case can be O(n). Why use stack?
On Wed, Jul 27, 2011 at 12:14 PM, salvador_cerinza
vishwakarma.ii...@gmail.com wrote:
Best case : O(n)
Worst
Can you please elaborate a little about your stack based solution. I was
thinking of using queue but was unable to make a perfect algo.
On Wed, Jul 27, 2011 at 12:18 PM, salvador_cerinza
vishwakarma.ii...@gmail.com wrote:
i m suggesting stack not just for best case only .
On Wed, Jul 27,
Let say stack S.
1.insert elements in S of A[] from right to left.
2.int val = S.top();
3.S.pop();
4.now check val with S.top() until u find any element smaller than val.
5.Note down the element pop it from stack
6.if step 4 is true , the push val in stack S and all elements which were
popped in
Following is the working code :Time complexity : O(n^2) Space
complexity : O(1)
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
/*num is the number which is searched in the array arr[]. index is the index
in the array arr[] by which the searched number is to
void quicksort( T[] A, Integer left, Integer right)
if ( left right )
q = partition( A, left, right) ;
quicksort ( A, left, q–1);
quicksort ( A, q+1, right) ;
Integer partition( T[] A, Integer left, Integer right)
m = left + right / 2;
swap( A[left], A[m]);
pivot = A[left] ;
lo =
O(nlogn)
1. precompute the minimum of [ i+1 N] and store in b[i]
2. Now do a binary search for a[i] in b[i+1] in the range of b[i+1. N]
On Wed, Jul 27, 2011 at 12:27 PM, salvador_cerinza
vishwakarma.ii...@gmail.com wrote:
Let say stack S.
1.insert elements in S of A[] from right to
There is a Book: Advance Programming in Unix Environment by Richard Stevens
in Chapter 2 i think there is a code that does the job of directory Listing
for given Directory
this is the code - for directory listing
*#include dirent.h
int main(int argc, char *argv[])
{
DIR *dp;
struct
@sunny
consider *uncompressed* suffix tree, even with distinct elements maximum
number of nodes with string length n formed will be 2n.
once suffix tree is constructed, needs to traverse in dfs order appending
the node found on the way.
total complexity would be O(construction of suffix tree ) +
Anyone got this book?? pdf.. or URL link is highly appreciated.
Thx..
On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg ankurga...@gmail.com wrote:
+1
Me too looking out for the same :(
On Tue, Jul 26, 2011 at 7:10 PM, Saravanan T mail2sarava...@gmail.comwrote:
+1
Pls send to my email id as
But still Printing O(N^2) substrings will take O(N^2) time isn't it ?
On Wed, Jul 27, 2011 at 12:39 PM, surender sanke surend...@gmail.comwrote:
@sunny
consider *uncompressed* suffix tree, even with distinct elements maximum
number of nodes with string length n formed will be 2n.
once
Implement Preorder Traversal in the File system tree.
--
On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote:
Function to display the directory structure in a user friendly way taking
root dir as arg
for a general OS. You may assume and state some basic APIs
I think it's wrong approach. Can you explain with an example?
On Wed, Jul 27, 2011 at 12:33 PM, pacific :-) pacific4...@gmail.com wrote:
O(nlogn)
1. precompute the minimum of [ i+1 N] and store in b[i]
2. Now do a binary search for a[i] in b[i+1] in the range of b[i+1. N]
On Wed,
yes Preorder recursion will be good for displaying in User Friendly way...
On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote:
Implement Preorder Traversal in the File system tree.
--
On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote:
Function
plz send it to my maid id also . thanks in advance :)
On Wed, Jul 27, 2011 at 12:46 PM, Prem Krishna Chettri
hprem...@gmail.comwrote:
Anyone got this book?? pdf.. or URL link is highly appreciated.
Thx..
On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg ankurga...@gmail.com wrote:
+1
Me too
can some one give me the code plz?
On Wed, Jul 27, 2011 at 12:26 AM, sunny agrawal sunny816.i...@gmail.comwrote:
yes Preorder recursion will be good for displaying in User Friendly way...
On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote:
Implement Preorder Traversal
Here: http://goo.gl/pDG5s
(Yes, that's the correct link)
--
On Wed, Jul 27, 2011 at 1:18 PM, malay chakrabarti m1234...@gmail.comwrote:
plz send it to my maid id also . thanks in advance :)
On Wed, Jul 27, 2011 at 12:46 PM, Prem Krishna Chettri hprem...@gmail.com
wrote:
Anyone got
*
/ \\
a bc
/\
b c
/
c
prints *a*
comes to b, appends a with bprints *ab*
comes to c ,appends ab with c prints *abc*
starts with new child
prints *b*
prints *bc*
prints *c*
surender
On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal
selection sort is best to do this
find the number of elements smaller or equal then the ith element of ather
array and swap it accordingly
On Wed, Jul 27, 2011 at 12:28 PM, ankit sambyal ankitsamb...@gmail.comwrote:
Following is the working code :Time complexity : O(n^2) Space
Another point of view:
Since both the arrays have same elements, sorting one sorts both.
Hence we can use elements of array1 to build a min-heap in array2.
Then read mins from array2 into array1, getting array1 sorted.
Copy array1 to array2.
Does this violate the comparison rule set?
--
On
Here is a Java code :
*private static void _printTree(String root,int depth)
{
if(root==null || root.trim().length()==0)
return;
File f=new File(root);
if(f.isFile()==true)
{
printTab(depth);
i don't find difference between your suffix tree approach and my simple
O(N^2) method
in both cases printf statement will be executed O(N^2) times
and in Suffix Tree approach will take some extra time of construction of
tree and extra space too !
On Wed, Jul 27, 2011 at 1:45 PM, surender
@anand: How are you building minheap ?? Comparison of same array elements
is not allowed !
--
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,
@ sunny , ur right!!
surender
On Wed, Jul 27, 2011 at 1:58 PM, sunny agrawal sunny816.i...@gmail.comwrote:
i don't find difference between your suffix tree approach and my simple
O(N^2) method
in both cases printf statement will be executed O(N^2) times
and in Suffix Tree approach will take
@ankit: you are right. While building is okay (item to insert is from other
array, hence comparison to that allowed), deletemin() will violate the
condition given.
--
On Wed, Jul 27, 2011 at 2:03 PM, ankit sambyal ankitsamb...@gmail.comwrote:
@anand: How are you building minheap ??
Can anyone suggest some good resources to master multithreaded programming
in C++
--
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
@sunny : what you means by machine dependent means 64 bit: you means by
compiler / operating system /computer architecture ?
because i never get size of pointer 8 byte. if your statement true then tell
me which compiler / operating system /computer architecture i should have
get this output 8.
computer architecture !!!
64 bit machine has word size of 8 bytes so pointers are of 8 bytes
you never got size as 8 byte because u might be working on a 32 bit machine
!!
On Wed, Jul 27, 2011 at 2:18 PM, hary rathor harry.rat...@gmail.com wrote:
@sunny : what you means by machine dependent
On Wed, Jul 27, 2011 at 2:18 PM, hary rathor harry.rat...@gmail.com wrote:
@sunny : what you means by machine dependent means 64 bit: you means by
compiler / operating system /computer architecture ?
because i never get size of pointer 8 byte. if your statement true then
tell me which
hmm o(nlogn) was for constructing the tree.Btw sorry for being unclear.
The best solution is the obvious one in this case.
On Wed, Jul 27, 2011 at 2:10 PM, surender sanke surend...@gmail.com wrote:
@ sunny , ur right!!
surender
On Wed, Jul 27, 2011 at 1:58 PM, sunny agrawal
#includestdio.h
# define MAXROW 3
#define MAXCOL 4
int main()
{
int (*p)[MAXCOL];
p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
printf(%d %d,sizeof(p),sizeof(*p));
system(pause);
return 0;
}
THE O/P IS 4 16.
I am not getting the reason.plss help
--
You received this message
The system on which u executed this will allocate 4 bytes for int type.
hence sizeof(p) gives 4 bytes and sizeof(*p) will contain 4 such integer
pointers( int *p[4] is the declaration) which gives 4*4=16 bytes
Regards
Ramya
*Try to learn something about everything and everything about
p is a pointer to an array of 4 ints.
sizeof(p) gives the size of the pointer which is an int and sizeof(*p)
gives the size of the array it points (4*4=16)
On Jul 27, 3:44 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
#includestdio.h
# define MAXROW 3
#define MAXCOL 4
int main()
{
thanks ankit and ramya..:)
On Wed, Jul 27, 2011 at 5:42 PM, Ankit ankitchaudhar...@gmail.com wrote:
p is a pointer to an array of 4 ints.
sizeof(p) gives the size of the pointer which is an int and sizeof(*p)
gives the size of the array it points (4*4=16)
On Jul 27, 3:44 pm, Kamakshii
one more question.
how to dynamically allocate memory for int *a[3]; ?
On Wed, Jul 27, 2011 at 5:57 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
thanks ankit and ramya..:)
On Wed, Jul 27, 2011 at 5:42 PM, Ankit ankitchaudhar...@gmail.com wrote:
p is a pointer to an array of 4 ints.
value of k in any if case would be k=m+n-1, now analyse both of the
options
i)jm, k=n+j-1, and a[n-1]b[j] if i=n
ii)in,k=m+i-1, and b[m-`1]=a[i] if j=m
for 1st case k=n+j-1 and jm so km+n-1 which is false
for 2nd case k=m+i-1 and in so km+n-1 which is also false so both
statement are false
ans:c
@rajeev
i ran dis code
int main()
{
char str[80];
strcpy(str,siva);
scanf(%[^india],str);
printf(%s,str);
return 0;
}
and i got the output as siva...instead of s as expected...can u plz point
out the error
On Tue, Jul 26, 2011 at 11:21 PM, siva viknesh sivavikne...@gmail.comwrote:
Hi,
Basically I am trying to create a blocked linked list(unrolled linked
list) with following properties
- Configurable number of elements in each node
- No duplicate elements in the unrolled linked list
- Linked list is sorted either during insertion or after creating the
linked list
- In place
Static variable needs to be defined outside cpp class. inside the class we
dint difine it but just declared it.
So size to be considered is just 1 int variable.
On Wed, Jul 27, 2011 at 2:29 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
int *a[3];
a= (int *[3]) malloc( 3*sizeof(*a));
Regards
Ramya
--
*Try to learn something about everything and everything about something*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@aditi : What is the string input you gave.?? it depends on that
If you have entered the string such as illeana then string illeana
matches at the first location , so it prints the previous value copied into
the str i.e siva .
Hope you understood .
On Wed, Jul 27, 2011 at 1:24 AM, aditi garg
what do you exactly mean by
(int *[3]) ?
On Wed, Jul 27, 2011 at 6:27 PM, ramya reddy rmy.re...@gmail.com wrote:
int *a[3];
a= (int *[3]) malloc( 3*sizeof(*a));
Regards
Ramya
--
*Try to learn something about everything and everything about something*
--
You received this message
int * [3] represents that 'a' is a integer pointer array of size 3.
--
Regards
Ramya
*
*
*Try to learn something about everything and everything about something*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
Do anybody of you know what type of questions cisco ask from electronics
part?
Please if anybody know then tell me some sample questions. And if possible
what topics should i cover?
Thanks in advance
--
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD
--
You received
Well in my interview for internship I was mainly asked basic questions from
Networking like FTP/HTTP, layers in networking, HTTPS, etc.
Some programming questions like what structures will you use in storing
millions of data (basically how google stores web caches) ?, etc (normal
like any other
@magesh:so acc to you the code below should give error?
#includestdio.h
int main(int argc,char *argv[])
{
char const *s=;
char str[]=hello;
s=str;
while(*s){
printf(%c,*s++);
}
system(pause);
return 0;
}
On Wed, Jul 27, 2011 at 7:12 PM, mageshthegr...@gmail.com
checking for anagrams itself will work for this question...
by using an array[[256];
On Wed, Jul 27, 2011 at 2:52 AM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
I dint get wat are you speaking of.each alphabet is mapped onto
ascii_val-'a' ie ascii of a=97. now check for odd and even occurence
if i declare a string constant inside another function
like let us say
,
int how()
{
char *s=hello;
return s;
}
so when how() get executed , the memory for hello will remain reserved or it
can be allocated to others. Will it amount to memory leak ?
--
Ankur Khurana
Computer Science
Netaji
@piyush:thanks...i got my mistake
On Wed, Jul 27, 2011 at 7:30 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
char const *s and const char *s are both same...try using char *const s..it
will give error then
On Wed, Jul 27, 2011 at 7:21 PM, Kamakshii Aggarwal kamakshi...@gmail.com
wrote:
hello is a string literal and this is what the C standard says about
string literals:
The multibyte character sequence is then used to initialize an array of
static storage duration and length just
sufficient to contain the sequence.
So memory will remain reserved for hello for the entire
Given a string of length 5 (example abcde), write a program to print all
the possible combinations OF LENGTH 3.
In this case : abc, abd, abe, acd, ace, ade, bcd, bce, bde, cde
Can someone provide a working code?
--
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT,
No it will not cause a memory leak as its a string literal and it behaves
more like a read only entity.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
One more thread is running parallel on the same topic
Please refer :
http://comments.gmane.org/gmane.comp.programming.algogeeks/17279
On Wed, Jul 27, 2011 at 7:39 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:
Given a string of length 5 (example abcde), write a program to print
@All: Please pay attention to CodeHunter's answer. This is a standard Nuts
and Bolts problem.
For those of you that are not aware, the Nuts and Bolts problem is as
follows:
Given an array of nuts and another array of bolts, we need to match up all
the nuts with all the bolts.
The constraint
is it lyk for {1,2,3
4,5,6,
7,8,9}
to be {3,2,1,
6,5,4,
9,8,7}??
On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan deok...@gmail.com wrote:
rotate a 2D matrix by angle 180
--
**With Regards
Deoki Nandan Vishwakarma
*
*
--
You
#include cstdio
#include cstring
using namespace std;
const int MX = 1000;
int n, k;
char str[MX], partial[MX];
void solve(int pos, int aux) {
if(aux==k) {
partial[aux] = 0;
printf(%s\n, partial);
return;
}
for(int i = pos; i n; i++) {
partial[aux]
m nt getting correct output for this program can any1 tell me wats the error
#includeiostream.h
#includeconio.h
#includestring.h
void main()
{
char a[]=Hello daughter;
couta\n;
int l,i,j,k,c;
int temp;
l=strlen(a);
for(i=0;il/2;i++)
{
temp=a[i];
a[i]=a[l-i-1];
a[l-i-1]=temp;
}
Any idea about results ?
On Jul 26, 4:20 pm, Mukul Gupta mukulnit...@gmail.com wrote:
here is one good tutorial on
topcoderhttp://www.topcoder.com/tc?module=Staticd1=tutorialsd2=usingTries May
be
this can help you.
On Sun, Jul 24, 2011 at 3:51 AM, Akash Mukherjee akash...@gmail.com
Hi there,
I have two questions,
Why sizeof(main) == 1 ? (sizeof(func) == 1).
Not 4 bytes ?.sizeof(void) == 1 too.
And this code doesn't stackoverflow ?
int main() {
sizeof(main());
}
Thanks,
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
#include cstdio
#include algorithm
using namespace std;
const int MX = 1000;
int n, m;
int a[MX][MX];
int main() {
scanf(%d%d, n, m);
for(int i = 0; i n; i++)
for(int j = 0; j m; j++)
scanf(%d, a[i][j]);
for(int i = 0; i n/2; i++)
for(int j = 0; j m;
I believe the method written is incorrect, it didnt work for me
i guess this is the right way...worked for me:
int **p;
p=malloc(3*sizeof(int *));
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
i am not getting any of the ways..can u explain?
On Wed, Jul 27, 2011 at 9:06 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote:
I believe the method written is incorrect, it didnt work for me
i guess this is the right way...worked for me:
int **p;
p=malloc(3*sizeof(int *));
--
You
Hmm, I don't get the question.
how to dynamically allocate memory for int *a[3]; ?
What do you mean by allocating memory for int *a[3];
Can you explain in some more details what exactly you want to do
On Jul 27, 8:39 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote:
i am not getting any of
I am not sure about the first question, but if you use sizeof(main()),
it gives the ans 4.
vishal@ubuntu:~/progs/c\ 09:12:57 PM $ cat alg.c
#includestdio.h
int main()
{
printf(%d\n,sizeof(main()));
return 0;
}
vishal@ubuntu:~/progs/c\ 09:13:00 PM $ gcc alg.c
vishal@ubuntu:~/progs/c\
Look we wish to allocate memory for an array of 3 integer pointers.
so when we do dynamic allocation we always store the result in a pointer to
the required data type.
for example if you wish to dynamically allocate int arr[3[]
u will write :
int *p=malloc(3*sizeof(int));
So now when you do it
No. it's wrong.
sizeof(main()) == sizeof(int) because main return integer.
i
- Mail original -
De : Vishal Thanki vishaltha...@gmail.com
À : algogeeks@googlegroups.com
Cc :
Envoyé le : Mercredi 27 Juillet 2011 15h45
Objet : Re: [algogeeks] sizeof() question.
I am not sure about the
Great solution amit. Thanks.
On Wed, Jul 27, 2011 at 8:30 PM, amit amit.codenam...@gmail.com wrote:
#include cstdio
#include cstring
using namespace std;
const int MX = 1000;
int n, k;
char str[MX], partial[MX];
void solve(int pos, int aux) {
if(aux==k) {
partial[aux] = 0;
The *sizeof* operator cannot be used with the following operands:
- Functions. (However, *sizeof* can be applied to pointers to functions.)
- Bit fields.
- Undefined classes.
- The type *void*.
- Dynamically allocated arrays.
- External arrays.
- Incomplete types.
-
#includestdio.h
#includeconio.h
void main()
{
clrscr();
int x=1,y=1,z=1;
x+=y+=z;
printf(\n %d\n ,xy?y:x);
printf(\n %d\n,xy?x++:y++);
printf(\n %d %d\n,x,y);
printf(\n %d\n,z+=xy?x++:y++);
printf(\n %d %d %d\n,x,y,z);
x=3;y=z=4;
printf(\n %d\n,z=y=x?1:0);
printf(\n %d\n,z=yy=x);
getch();
}
I m
sizeof(main()) == sizeof(int) because main return integer.
But main isn't invoked, sizeof does all thing at compile time.
On Wed, Jul 27, 2011 at 9:27 PM, Charlotte Swazki
charlotteswa...@yahoo.frwrote:
No. it's wrong.
sizeof(main()) == sizeof(int) because main return integer.
i
-
Thanks a lot !
De : Abhinav Arora abhinavdgr8b...@gmail.com
À : algogeeks@googlegroups.com
Cc : Charlotte Swazki charlotteswa...@yahoo.fr
Envoyé le : Mercredi 27 Juillet 2011 16h02
Objet : Re: sizeof() question.
The sizeof operator cannot be used with the
Hi
The solution in the link is of complexity (n*2^n))
Does anyone know any better solution ?
Regards
Ankur
On Tue, Jul 26, 2011 at 11:10 PM, rajeev bharshetty rajeevr...@gmail.comwrote:
@Ankur The link does has a very good explanation. Nice solution :)
On Tue, Jul 26, 2011 at 10:47 PM,
it's 11.
i think you juste write out of the a[] array, so '\0', can be at a[4], or a[7]
etc... and strlen can change. (the output of this program is 11 for me).
De : Shantanu Sachdev shantanumn...@gmail.com
À : algogeeks@googlegroups.com
Envoyé le : Mercredi
What is the BEST-WORST case time to add and remove elements from a queue
that has been implemented with the help of 2 stacks.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
#includestdio.h
#includeconio.h
void main()
{
clrscr();
int x,y,z;
x=y=z=1;
printf(\n %d,++x||++y++z);
printf(\n %d %d %d ,x,y,z);
x=y=z=1;
printf(\n %d,++x++y||++z);
printf(\n %d %d %d,x,y,z);
x=y=z=1;
printf(\n %d,++x++y++z);
printf(\n %d %d %d,x,y,z);
x=y=z=-1;
printf(\n %d,++x++y||++z);
what do u mean by o/p..actually what r u asking for..sorry to ask
so..i couldn't get u..
On 7/27/11, Vijay Khandar vijaykhand...@gmail.com wrote:
#includestdio.h
#includeconio.h
void main()
{
clrscr();
int x,y,z;
x=y=z=1;
printf(\n %d,++x||++y++z);
printf(\n %d %d %d ,x,y,z);
x=y=z=1;
C i guess ur comfortable wid the frst 3...
now in fourth c the order of evaluation frst xy is evaluated as has
higher precedence that +=...since both r 3...so condition is false and y++
is taken...so z+=y++ takes place...
z ws 1 and y=3...so z becomes 4 and it is printed... and after this y
I m getting o/p
1
2 1 1
1
2 2 1
but on wards when x=y=z= -1
then i m getting something different o/p.
On Wed, Jul 27, 2011 at 10:18 PM, Jnana Sagar supremeofki...@gmail.comwrote:
what do u mean by o/p..actually what r u asking for..sorry to ask
so..i couldn't get u..
On 7/27/11, Vijay
i made some mistake...and yea wid input siva output is s..:)
On Wed, Jul 27, 2011 at 6:26 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
but what input did u give??
if u r giving i/p as siva o/p will be s only
On Wed, Jul 27, 2011 at 1:24 AM, aditi garg aditi.garg.6...@gmail.comwrote:
@DK.perfect explanation :)
On Jul 27, 8:14 pm, Rajeev Kumar rajeevprasa...@gmail.com wrote:
@All : very good article on this
:http://tech-queries.blogspot.com/2011/01/nuts-and-bolts-algorithm.html
On Wed, Jul 27, 2011 at 7:49 AM, DK divyekap...@gmail.com wrote:
@All: Please pay
No. rectangles in NxN matrix
... is it n^2 + (n-2) ??
--
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
#includestdio.h
#includeconio.h
int f(int n)
{
if(n=1)
{
printf( %d,n);
}
else
{
f(n/2);
printf( %d,n%2);
}
}
void main()
{
clrscr();
f(173);
getch();
}
o/p-1 0 1 0 1 1 0 1
but i m getting 1 0 1 1 0 1 0 1
plz explain me...
--
You received this message because you are subscribed to
@abhinav:thanks.:)
On Wed, Jul 27, 2011 at 9:23 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote:
Look we wish to allocate memory for an array of 3 integer pointers.
so when we do dynamic allocation we always store the result in a pointer to
the required data type.
for example if you wish to
no we cant..
coz when we do say int *p=4000;
its fine till now.. and if we do *p=10; it is segmentation fault..
On Wed, Jul 27, 2011 at 10:35 PM, rShetty rajeevr...@gmail.com wrote:
Usually when I declare a variable it will be stored in memory location
with some address .
Such as consider I
It will be (1+2+3+,,,+n)^2.u can verify it for a chess board hich will
have 1296 rectangles for n=8
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
I am getting the proper output :) 1 0 1 0 1 1 0 1
*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*
On Wed, Jul 27, 2011 at 11:19 PM, Vijay Khandar vijaykhand...@gmail.comwrote:
#includestdio.h
#includeconio.h
int f(int n)
{
if(n=1)
{
printf( %d,n);
}
Passing a pointer across functions does not create any problem and doesn't
cause memory leak. but passing an array ,for eg
int *fun()
{
int a[12];
return a;
}
this creates memory leak as the call stack no more holds the array. So, in
essence, though int *a and int a[] behave quite similarly
Can anyone give an O(n) solution pls...??
I think the above code is an O(n^2) solution..
if i am not wrong...!!!
On 7/27/11, amit amit.codenam...@gmail.com wrote:
#include cstdio
#include algorithm
using namespace std;
const int MX = 1000;
int n, m;
int a[MX][MX];
int main() {
The output is 10101101
consider it to be f(173) - f(86) - f(43) - f(21) - f(10) - f(5) - f(2)
- f(1)
1 0 110
1 01
Hope you get the recursion there .
On Wed, Jul 27, 2011 at 11:19 PM, Vijay Khandar
If you meant rotate a 2D matrix by angle 180 of order n x n
Then you cannot have a O(n) algo, Each of the n^2 elements must be
accessed so you cannot have anything less than n^2
On Jul 27, 10:59 pm, Puneet Gautam puneet.nsi...@gmail.com wrote:
Can anyone give an O(n) solution pls...??
I think
@nikhil:So what u mean is that if i have:
struct{
int a;
char b[5];
};
the size of this struct's node will be 12 not 9.., to make it a multiple of 4??
On 7/26/11, Nikhil Gupta nikhilgupta2...@gmail.com wrote:
Padding is not a topic of self referential structure.
Padding means that extra
if u hv say 20 million records and u have to create a b+ tree then you
might be storing 20 million pointers at the leaf levelhow can u
optimize this(using b+ tree only)???
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
Which of the following data structure do better job (has lesser time
complexity) at searching elements that has a worst-case time
complexity of O(n)? Do not account for the cost of building the Data
structure in searching cost.
a) Linked list with element sorted by value
b) Binary tree with no
1 - 100 of 138 matches
Mail list logo