[algogeeks] Complicated declaration C

2012-10-30 Thread rahul sharma
void(*f)(void(*)(int*,void **),int(*)(void**,int*));


f is a fxn pointer to fxn which takes 2 args and teturn nothing

2 arguments are

1. pointer to function which returns nothing and takes 2 args one pointer
to int and pointer to pointer to void
2. pointer to fxn returning int and takes 2 args as pointer to void pointer
and pointer to int..


This is as per me but in book highlighted int above in red as 2 argument is
replaced by int*..so i wana ask whether 2 argument returning int pointer or
int ..Accoring to me its int..please reply asap

Thnx

-- 
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] Repeated values

2012-10-30 Thread Don
Given an array of N integers in the range 0..N-1, determine if any
number is repeated in the array.
Solution should execute in O(n) time and use constant space.
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.



Re: [algogeeks] Repeated values

2012-10-30 Thread arumuga abinesh
if sum of all elements = n(n-1)/2 , no elements are repeated
else some numbers are repeated

On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:

 Given an array of N integers in the range 0..N-1, determine if any
 number is repeated in the array.
 Solution should execute in O(n) time and use constant space.
 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.



-- 
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: C Macro

2012-10-30 Thread Ankit Tripathi
Besides i prefer to write the following #define which is generic and works 
in all case, i.e., it doesn't matter whether you pass pointers, float, int, 
etc;

*#define swap( a, b )size_t t; t = a; a = b; b = t;*

1 more thing now you don't have to pass any other information i.e., whether 
your arguments are int, float *, etc. 

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/uCkZLzW-Qy8J.
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] Pre/Post L and r value

2012-10-30 Thread Saurabh Kumar
Post increment returns temp object because it has to return the old value
of object not the new incremented one:
Simply put, the code for post increment somewhat goes like this:

int operator++ (int n){
int temp = n;
n = n+1;
return temp;
}

that's also the reason you cannot use it as a lvalue in an exprression, as
you would be assigning nowhere.

On 27 October 2012 20:09, rahul sharma rahul23111...@gmail.com wrote:

 But y post returns temp. object


 On Fri, Oct 26, 2012 at 8:18 PM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 i++: Post increment can't be a lvalue because Post increment internally
 returns a temporary object (NOT the location of i) hence you cannot assign
 anything to it. The result of i++ can be used only as a rvalue.
  ++i: whereas, in Pre-increment  value gets incremented and the same
 location is returned back to you, hence can be used as lvalue in an
 expression.(C++ allows this)
 Both can be used as rvalues though.

 On 26 October 2012 18:54, rahul sharma rahul23111...@gmail.com wrote:

  why pre inc. is l value and post is r value..please 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.


  --
 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: Complicated declaration C

2012-10-30 Thread Ankit Tripathi
Your interpretation is right, i.e., the second argument returns an int.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/6iB_TkYbdUYJ.
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] Informatica written que : C output

2012-10-30 Thread Rahul Kumar Patle
can anyone explain the reason for weird output producing by this code..
it is giving output hello many time 30 but as code's logic it should print
only 9 time
it runs correctly when i comment out statements inside else{}
thanks in advance

#includestdio.h
#includestdlib.h
int count = 0;
main()
{
int tmp[10] , i;
int n = 0;
for(i=0;i9;i++)
{
tmp[i]=fork();
if(tmp[i]0)
break;
else
{
//count++;
printf(Hello);
//printf( %d - %d \n , tmp[i], count);
}
}
}

-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 
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: Range Checking Efficiently C++

2012-10-30 Thread Atul Singh
i have attached a file consisting first by comparison and second by XORING
biku,.,. u shuld have a look at that..

-- 
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.


0   =  0  0   FALSEFROM COMPARISON
0   =  00 FALSE   FROM  XORING

0   =  1  0   FALSEFROM COMPARISON
0   =  10 TRUEFROM  XORING

0   =  2  0   FALSEFROM COMPARISON
0   =  20 TRUEFROM  XORING

0   =  3  0   FALSEFROM COMPARISON
0   =  30 TRUEFROM  XORING

0   =  4  0   FALSEFROM COMPARISON
0   =  40 TRUEFROM  XORING

0   =  5  0   FALSEFROM COMPARISON
0   =  50 TRUEFROM  XORING

0   =  6  0   FALSEFROM COMPARISON
0   =  60 TRUEFROM  XORING

0   =  7  0   FALSEFROM COMPARISON
0   =  70 TRUEFROM  XORING

0   =  8  0   FALSEFROM COMPARISON
0   =  80 TRUEFROM  XORING

0   =  9  0   FALSEFROM COMPARISON
0   =  90 TRUEFROM  XORING


0   =  0  1   TRUE FROM COMPARISON
0   =  01 FALSE   FROM  XORING

0   =  1  1   FALSEFROM COMPARISON
0   =  11 TRUEFROM  XORING

0   =  2  1   FALSEFROM COMPARISON
0   =  21 TRUEFROM  XORING

0   =  3  1   FALSEFROM COMPARISON
0   =  31 TRUEFROM  XORING

0   =  4  1   FALSEFROM COMPARISON
0   =  41 TRUEFROM  XORING

0   =  5  1   FALSEFROM COMPARISON
0   =  51 TRUEFROM  XORING

0   =  6  1   FALSEFROM COMPARISON
0   =  61 TRUEFROM  XORING

0   =  7  1   FALSEFROM COMPARISON
0   =  71 TRUEFROM  XORING

0   =  8  1   FALSEFROM COMPARISON
0   =  81 TRUEFROM  XORING

0   =  9  1   FALSEFROM COMPARISON
0   =  91 TRUEFROM  XORING


0   =  0  2   TRUE FROM COMPARISON
0   =  02 FALSE   FROM  XORING

0   =  1  2   TRUE FROM COMPARISON
0   =  12 TRUEFROM  XORING

0   =  2  2   FALSEFROM COMPARISON
0   =  22 TRUEFROM  XORING

0   =  3  2   FALSEFROM COMPARISON
0   =  32 TRUEFROM  XORING

0   =  4  2   FALSEFROM COMPARISON
0   =  42 TRUEFROM  XORING

0   =  5  2   FALSEFROM COMPARISON
0   =  52 TRUEFROM  XORING

0   =  6  2   FALSEFROM COMPARISON
0   =  62 TRUEFROM  XORING

0   =  7  2   FALSEFROM COMPARISON
0   =  72 TRUEFROM  XORING

0   =  8  2   FALSEFROM COMPARISON
0   =  82 TRUEFROM  XORING

0   =  9  2   FALSEFROM COMPARISON
0   =  92 TRUEFROM  XORING


0   =  0  3   TRUE FROM COMPARISON
0   =  03 

Re: [algogeeks] C Function Pointer(Typedef)

2012-10-30 Thread Saurabh Kumar
because, pFunc is just a typedef.
you'd have to instantiate a variable at least in order to call your
function.
like -
 typedef int (*pFunc) (int);
 pFunc fptr = func; //fptr is now a variable on stack which points to your
function.
 fptr(5); // call that function.

On 30 October 2012 01:41, rahul sharma rahul23111...@gmail.com wrote:

 #include stdio.h
 #include stdlib.h


 int func(int);
 int main(int count,char *argv[])
 {
  typedef int (*pFunc) (int);
 pFunc=func;
 getchar();
 }




 Y itz not compiling?

 --
 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] @Walmart Labs interview questions

2012-10-30 Thread Shyam Sundar
Hi all,

Has Walmart Labs visited any of your campuses this year? If so, can anyone
please provide the details about the interview process and the questions
that were asked?


Thanks
Shyam Sundar

-- 
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: #in macros

2012-10-30 Thread Vikram Pradhan
Macro arguments are scanned and expanded before the substitution in macro
body unless they are convert to a string representation (using #) or
concatenated with other tokens (using ##).

Xstr(oper)  = Xstr(multiply) =str(multiply)=multiply// in Xstr(x)
, x is a simple argument so it will expand fully

str(oper)=oper// in str(x) , x is converting to string so it
will not get expanded

check this link :
http://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html#Argument-Prescan




On Sun, Oct 28, 2012 at 3:28 PM, rahul sharma rahul23111...@gmail.comwrote:

 And when char *opername=str(oper);

 then o/p is operwhy behaviour is diff. in 2 cases

 On Sun, Oct 28, 2012 at 2:53 PM, rahul sharma rahul23111...@gmail.comwrote:

 #includestdio.h
 #include str(x) #x
 #define Xstr(x) str(x)
 #define oper multiply


 int main()
 {
 char *opername=Xstr(oper);
 printf(%s,opername);
 }
 so firstly Xstr is expanded to str(oper)
 then str(oper) is expanded to #oper now i have read that

 If, however, a parameter name is preceded by a # in the replacement text,
 the
 combination will be expanded into a quoted string with the parameter
 replaced by the actual argument...and in this case actual is also oper so
 it becomes oper...so it should print oper .i thnik i am mistaken
 anyhre...correct???


  --
 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.




-- 
Vikram Pradhan | B.Tech| Computer Science  Engineering | NIT Jalandhar  |
9740186063 |

-- 
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] C Macro

2012-10-30 Thread Vikram Pradhan
@rahul : dude it's working fine ...check your printf() statement you
are swapping the pointers and printing the original float values of a and x
it should be printf(%f%f,*p,*q);

or if you want to swap float values not the pointers then it should be
swap(a,x,float);
printf(%f%f,a,x);


On Mon, Oct 29, 2012 at 11:30 PM, atul anand atul.87fri...@gmail.comwrote:

 well they should not , if you see it closely  pointer p and q
 contain contain address of a and x.
 and swap() macro will swap value these pointers are holding i.e adress
 of a and xbut will it reflect address of a and x ???...NO
 so if you print the address p and q ...before and after the swap then
 you should see that after swap p will be holding address of x and
 q will be holding address of a..that it

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  I have taken form book...i am writing exact code
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t;
 
 
  int main()
  {
  float a,x;
  a=20.0;
  x=30.0;
  float *p,*q;
  p=a,q=x;
  swap(p,q,float*);
  printf(%f %f,a,x);
  getchar();
  }
 
  o/p=20.000 30.000
 
 
  why not swapped???
  On Mon, Oct 29, 2012 at 11:01 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  if you think the your expanded version is incorrect.You are wrong ,
  because int * will hold pointer but you are not allocating address of
  x ..instead you are allocating x value as an address of x to *t.This
  wont work.
  so to make it work you need to save the address of x and y in temp
  pointers i.e
 
 int *p.*q;
  p=x;
  q=y;
  int t;
  t=*p;
  *p=*q;
  *q=t;
  now you can convert it into macro.
 
  On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
   @atul...mistakenly  i have put w at place of t in my last post...i
 wana
  say
  
  
  
   On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com
 wrote:
  
   Just replace your macro with its definition and you will understand.
  
   its not doing swapping of pointers...plz explain
  
  
  
   @dCode i expanded..but its fine...please tell
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
   int main
   int x=10,y=20;
   int *p,*q;
   swap(x,y,int*);
  
   int * t;
   t=x;
   x=y;
   y=t;
  
  
   There is int* at the end..there is som problem with my
   keyborad...:(.acc to me axpanded version is above..but not
  swapping
   two pointerssplz comment
  
  
  
  
   On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
   rahul23111...@gmail.comwrote:
  
   its now doing swapping of pointers...plz explain
  
  
   On Sun, Oct 28, 2012 at 8:08 PM, atul anand
   atul.87fri...@gmail.comwrote:
  
   it should swap
  
   On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
Why the following code is not able to swap two macros???although
it
is
easily swapping 2 variables
   
#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t
   
   
int main
   
   
int x=10,y=20;
int *p,*q;
   
swap(x,y,int);
   
--
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.
  
  
   --
   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 

Re: [algogeeks] INTERVIEW QUESTION

2012-10-30 Thread Saurabh Kumar
you are right.
k is the edit distance we are searching for and a critical parameter. In
short you can say- k represents how much error(in terms of edit-distance)
you want to tolerate for between document word 'w' and your suggestion.
since our data structure can answer queries for e.g. Find all words with
k=5) I think we can do better as loading the tree and searching could be
costly so, instead of repeatedly firing queries many times for k=1, 2,
3,...
i think it's better to do it like:

1. for a given document word 'w': you could start k = 0 (for exact
matching, i.e. if w is present in dictionary or not) if returned
list.size() =1 then its' a valid word else, if it's NULL fire a query for
k=2.
From the function return a list of all dictionary words which are
*=2*distance from 'w' and return a sorted list based on edit
distance.
sometimes returned list could be large so you need to filter out the Best
possible Suggestions for 'w'.
like- you might wanna give preference to those words which were 1 distance
away than 2. and in that - those edits which have the edited 'alphabet
close to the mispelled one'... like the example- w = REDT [REST is more
likely than RENT as 'S' appears closer to 'D' on keyboard than 'N'] etc. or
they sound same based on some phoneme model etc.

2. if for k=2 returned list was NULL, you can query for k=5, and check if
there are any words with edit-distance *=5*., again returned list could
possibly be NULL as well. you might want to limit your search for k (say
5). e.g. if document contains w = ijljhflkjjiulgihh  It's highly unlikely
that your dictionary will contain any word closer to this (unless ur
dictionary contains crazy volcano names from iceland):
so for cases like these, after k=5 you can return No Suggestion.

It's actually experimentative. you could try any other way also but this
way you can limit your no. of queries/per word to 2.


A correction: I realize previously I've interchangeably used teh name
'KDTree' and 'bk-tree', both are metric trees but what I really meant was a
'bkTree'. where, a node has arbitrary no. of children and the parent-child
edge represents the corresponding Levenshtein distance between them. The
basic idea here is to store your dictionary in a data-structure whcih
facilitates searching of words based on their edit-distances.


On 27 October 2012 22:40, payal gupta gpt.pa...@gmail.com wrote:

  the question mentioned is as it isi just copy pasted it here.
 @saurabh thanx for the explainaton of the cube problem i guess that is an
 appropriate soln for the question.
 and for the other question on detection of typos and  suggestion i would
 like to know to know what 'k' in your explaination stands for?how are the
 values allocated to it ? should it be for each wrong word not mentioned in
 the dictionary we got to check if the word exists with edit distance equal
 to 1 in dictioanry
 and so on until we get the correct word???




 on Sat, Oct 27, 2012 at 8:12 AM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 could you please share the link? coz at first glance a Trie looks like a
 bad choice for this task.

 I'd go with the Levenshtein distance and a kd-tree.
 First implement the Levenshtein distance algorithm to calculate the edit
 distance of two strings.
 Second, since Levenshtein distance qualifies as a metric space we can use
 a metric tree like BK-tree to populate it with our dictionary.
 Choose a random word from dictionary as a root and subsequently insert
 dictionary words(picking them up randomly) into the tree.
 A node has arbitrary no. of children. The parent-child edge represents
 the corresponding Levenshtein distance between them.

 Building the tree is one time process. Once the tree is built we can
 devise a way to serialize it and store it.

 Using this tree we can find all the words with edit-distance less than or
 equal to, say k.
 Lets, define a function call in Tree class as: List KDTreeSearch(s, k);
 which searches for all strings s' in the tree such that |s-s'| = k i.e.
 all strings which are less than or equal to an edit distance of k.
 Searching:
 Start with the Root and calculate the edit-distance of s from root. If
 its', say d then we know exactly which children we need to descend to in
 order to find the words with distance =k.

 Looking for typos:
 Scan the document and for each word 'w' make a call: list =
 KDTreeSearch(w, 0);
 if, list.size() = 1. //We have the word in dictionary.
 else, list = KDTreeSearch(w, 2); // searching for all words with edit
 distance of 2 from w

 returned 'list' can sometimes be large, we can subsequently filter it out
 by narrowing down our definition of 'typos'
 e.g. for typo w = REDT [REST is more likely than RENT] or maybe some
 Phoneme model etc you should discuss this at length with the
 interviewer.

 On 27 October 2012 07:03, Raghavan its...@gmail.com wrote:

 By any chance did you read the new blog post by Gayle Laakmaan..

 I guess to detect typos we can use some sort of Trie 

[algogeeks] Re: Repeated values

2012-10-30 Thread Don
Does your algorithm work if N=4 and the array is {1,1,2,2}.

Don

On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
 if sum of all elements = n(n-1)/2 , no elements are repeated
 else some numbers are repeated







 On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
  Given an array of N integers in the range 0..N-1, determine if any
  number is repeated in the array.
  Solution should execute in O(n) time and use constant space.
  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.

-- 
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] Pre/Post L and r value

2012-10-30 Thread rahul sharma
@saurabh..thnxplz provide me code snippet for pre increment also..it
will help a lot..i can guess it will do n++ and return itself..plz give
code snippet...

On Mon, Oct 29, 2012 at 10:50 AM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 Post increment returns temp object because it has to return the old value
 of object not the new incremented one:
 Simply put, the code for post increment somewhat goes like this:

 int operator++ (int n){
  int temp = n;
 n = n+1;
 return temp;
 }

 that's also the reason you cannot use it as a lvalue in an exprression, as
 you would be assigning nowhere.

 On 27 October 2012 20:09, rahul sharma rahul23111...@gmail.com wrote:

 But y post returns temp. object


 On Fri, Oct 26, 2012 at 8:18 PM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 i++: Post increment can't be a lvalue because Post increment internally
 returns a temporary object (NOT the location of i) hence you cannot assign
 anything to it. The result of i++ can be used only as a rvalue.
  ++i: whereas, in Pre-increment  value gets incremented and the same
 location is returned back to you, hence can be used as lvalue in an
 expression.(C++ allows this)
 Both can be used as rvalues though.

 On 26 October 2012 18:54, rahul sharma rahul23111...@gmail.com wrote:

  why pre inc. is l value and post is r value..please 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.


  --
 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.



Re: [algogeeks] Re: #in macros

2012-10-30 Thread rahul sharma
ossam link...thnx..vikram

On Tue, Oct 30, 2012 at 3:20 PM, Vikram Pradhan vpradha...@gmail.comwrote:

 Macro arguments are scanned and expanded before the substitution in macro
 body unless they are convert to a string representation (using #) or
 concatenated with other tokens (using ##).

 Xstr(oper)  = Xstr(multiply) =str(multiply)=multiply// in
 Xstr(x) , x is a simple argument so it will expand fully

 str(oper)=oper// in str(x) , x is converting to string so it
 will not get expanded

 check this link :
 http://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html#Argument-Prescan




 On Sun, Oct 28, 2012 at 3:28 PM, rahul sharma rahul23111...@gmail.comwrote:

 And when char *opername=str(oper);

 then o/p is operwhy behaviour is diff. in 2 cases

 On Sun, Oct 28, 2012 at 2:53 PM, rahul sharma rahul23111...@gmail.comwrote:

 #includestdio.h
 #include str(x) #x
 #define Xstr(x) str(x)
 #define oper multiply


 int main()
 {
 char *opername=Xstr(oper);
 printf(%s,opername);
 }
 so firstly Xstr is expanded to str(oper)
 then str(oper) is expanded to #oper now i have read that

 If, however, a parameter name is preceded by a # in the replacement
 text, the
 combination will be expanded into a quoted string with the parameter
 replaced by the actual argument...and in this case actual is also oper so
 it becomes oper...so it should print oper .i thnik i am mistaken
 anyhre...correct???


  --
 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.




 --
 Vikram Pradhan | B.Tech| Computer Science  Engineering | NIT Jalandhar  |
  9740186063 |

 --
 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] C Macro

2012-10-30 Thread rahul sharma
Yeah its working...actually it was written in book...and i did nt
compilemistake of author

On Tue, Oct 30, 2012 at 12:17 PM, Vikram Pradhan vpradha...@gmail.comwrote:

 @rahul : dude it's working fine ...check your printf() statement you
 are swapping the pointers and printing the original float values of a and x
 it should be printf(%f%f,*p,*q);

 or if you want to swap float values not the pointers then it should be
 swap(a,x,float);
 printf(%f%f,a,x);


 On Mon, Oct 29, 2012 at 11:30 PM, atul anand atul.87fri...@gmail.comwrote:

 well they should not , if you see it closely  pointer p and q
 contain contain address of a and x.
 and swap() macro will swap value these pointers are holding i.e adress
 of a and xbut will it reflect address of a and x ???...NO
 so if you print the address p and q ...before and after the swap then
 you should see that after swap p will be holding address of x and
 q will be holding address of a..that it

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  I have taken form book...i am writing exact code
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t;
 
 
  int main()
  {
  float a,x;
  a=20.0;
  x=30.0;
  float *p,*q;
  p=a,q=x;
  swap(p,q,float*);
  printf(%f %f,a,x);
  getchar();
  }
 
  o/p=20.000 30.000
 
 
  why not swapped???
  On Mon, Oct 29, 2012 at 11:01 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  if you think the your expanded version is incorrect.You are wrong ,
  because int * will hold pointer but you are not allocating address of
  x ..instead you are allocating x value as an address of x to *t.This
  wont work.
  so to make it work you need to save the address of x and y in temp
  pointers i.e
 
 int *p.*q;
  p=x;
  q=y;
  int t;
  t=*p;
  *p=*q;
  *q=t;
  now you can convert it into macro.
 
  On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
   @atul...mistakenly  i have put w at place of t in my last post...i
 wana
  say
  
  
  
   On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com
 wrote:
  
   Just replace your macro with its definition and you will understand.
  
   its not doing swapping of pointers...plz explain
  
  
  
   @dCode i expanded..but its fine...please tell
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
   int main
   int x=10,y=20;
   int *p,*q;
   swap(x,y,int*);
  
   int * t;
   t=x;
   x=y;
   y=t;
  
  
   There is int* at the end..there is som problem with my
   keyborad...:(.acc to me axpanded version is above..but not
  swapping
   two pointerssplz comment
  
  
  
  
   On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
   rahul23111...@gmail.comwrote:
  
   its now doing swapping of pointers...plz explain
  
  
   On Sun, Oct 28, 2012 at 8:08 PM, atul anand
   atul.87fri...@gmail.comwrote:
  
   it should swap
  
   On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
Why the following code is not able to swap two macros???although
it
is
easily swapping 2 variables
   
#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t
   
   
int main
   
   
int x=10,y=20;
int *p,*q;
   
swap(x,y,int);
   
--
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.
  
  
   --
   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 

Re: [algogeeks] Re: Repeated values

2012-10-30 Thread rahul sharma
Can we modify the array???we can make index we visit as negative and then
if any one already containing -ve..then its repeating

On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:

 Does your algorithm work if N=4 and the array is {1,1,2,2}.

 Don

 On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
  if sum of all elements = n(n-1)/2 , no elements are repeated
  else some numbers are repeated
 
 
 
 
 
 
 
  On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
   Given an array of N integers in the range 0..N-1, determine if any
   number is repeated in the array.
   Solution should execute in O(n) time and use constant space.
   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.

 --
 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: Repeated values

2012-10-30 Thread Don
We can modify the array. The algorithm should work even if we use
unsigned integers and N is the largest unsigned integer.

Don

On Oct 30, 4:42 pm, rahul sharma rahul23111...@gmail.com wrote:
 Can we modify the array???we can make index we visit as negative and then
 if any one already containing -ve..then its repeating







 On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:
  Does your algorithm work if N=4 and the array is {1,1,2,2}.

  Don

  On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
   if sum of all elements = n(n-1)/2 , no elements are repeated
   else some numbers are repeated

   On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
Given an array of N integers in the range 0..N-1, determine if any
number is repeated in the array.
Solution should execute in O(n) time and use constant space.
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.

  --
  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: Repeated values

2012-10-30 Thread rahul sharma
i thnik this is the solution...
http://www.geeksforgeeks.org/archives/9755

On Wed, Oct 31, 2012 at 2:20 AM, Don dondod...@gmail.com wrote:

 We can modify the array. The algorithm should work even if we use
 unsigned integers and N is the largest unsigned integer.

 Don

 On Oct 30, 4:42 pm, rahul sharma rahul23111...@gmail.com wrote:
  Can we modify the array???we can make index we visit as negative and then
  if any one already containing -ve..then its repeating
 
 
 
 
 
 
 
  On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:
   Does your algorithm work if N=4 and the array is {1,1,2,2}.
 
   Don
 
   On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
if sum of all elements = n(n-1)/2 , no elements are repeated
else some numbers are repeated
 
On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
 Given an array of N integers in the range 0..N-1, determine if any
 number is repeated in the array.
 Solution should execute in O(n) time and use constant space.
 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.
 
   --
   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: Repeated values

2012-10-30 Thread Don
That solution is using the sign bit as extra storage, which is clever,
but if you have an array of unsigned integers and N is more than have
of the largest unsigned integer, it won't work. There is a way to do
it without using the sign bit as extra storage.
Don

On Oct 30, 5:16 pm, rahul sharma rahul23111...@gmail.com wrote:
 i thnik this is the solution...http://www.geeksforgeeks.org/archives/9755







 On Wed, Oct 31, 2012 at 2:20 AM, Don dondod...@gmail.com wrote:
  We can modify the array. The algorithm should work even if we use
  unsigned integers and N is the largest unsigned integer.

  Don

  On Oct 30, 4:42 pm, rahul sharma rahul23111...@gmail.com wrote:
   Can we modify the array???we can make index we visit as negative and then
   if any one already containing -ve..then its repeating

   On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:
Does your algorithm work if N=4 and the array is {1,1,2,2}.

Don

On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
 if sum of all elements = n(n-1)/2 , no elements are repeated
 else some numbers are repeated

 On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
  Given an array of N integers in the range 0..N-1, determine if any
  number is repeated in the array.
  Solution should execute in O(n) time and use constant space.
  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.

--
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: Repeated values

2012-10-30 Thread Don
That solution is using the sign bit as extra storage, which is clever,
but if you have an array of unsigned integers and N is more than half
of the largest unsigned integer, it won't work. There is a way to do
it without using the sign bit as extra storage.

On Oct 30, 5:16 pm, rahul sharma rahul23111...@gmail.com wrote:
 i thnik this is the solution...http://www.geeksforgeeks.org/archives/9755







 On Wed, Oct 31, 2012 at 2:20 AM, Don dondod...@gmail.com wrote:
  We can modify the array. The algorithm should work even if we use
  unsigned integers and N is the largest unsigned integer.

  Don

  On Oct 30, 4:42 pm, rahul sharma rahul23111...@gmail.com wrote:
   Can we modify the array???we can make index we visit as negative and then
   if any one already containing -ve..then its repeating

   On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:
Does your algorithm work if N=4 and the array is {1,1,2,2}.

Don

On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
 if sum of all elements = n(n-1)/2 , no elements are repeated
 else some numbers are repeated

 On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
  Given an array of N integers in the range 0..N-1, determine if any
  number is repeated in the array.
  Solution should execute in O(n) time and use constant space.
  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.

--
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: Repeated values

2012-10-30 Thread Don
In addition, inputs such as {2,2,0} will fail because when you try to
make zero negative, it doesn't work so well.
Don

On Oct 30, 5:36 pm, Don dondod...@gmail.com wrote:
 That solution is using the sign bit as extra storage, which is clever,
 but if you have an array of unsigned integers and N is more than half
 of the largest unsigned integer, it won't work. There is a way to do
 it without using the sign bit as extra storage.

 On Oct 30, 5:16 pm, rahul sharma rahul23111...@gmail.com wrote:







  i thnik this is the solution...http://www.geeksforgeeks.org/archives/9755

  On Wed, Oct 31, 2012 at 2:20 AM, Don dondod...@gmail.com wrote:
   We can modify the array. The algorithm should work even if we use
   unsigned integers and N is the largest unsigned integer.

   Don

   On Oct 30, 4:42 pm, rahul sharma rahul23111...@gmail.com wrote:
Can we modify the array???we can make index we visit as negative and 
then
if any one already containing -ve..then its repeating

On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:
 Does your algorithm work if N=4 and the array is {1,1,2,2}.

 Don

 On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
  if sum of all elements = n(n-1)/2 , no elements are repeated
  else some numbers are repeated

  On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
   Given an array of N integers in the range 0..N-1, determine if any
   number is repeated in the array.
   Solution should execute in O(n) time and use constant space.
   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.

 --
 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] Ternary operators

2012-10-30 Thread Tamanna Afroze
both codes are same. Where is the difference?

-- 
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] Informatica written que : C output

2012-10-30 Thread atul anand
its seem to me that output buffer is not flushing ..to do so you need
to add \n while printing hello i.e
 printf(Hello\n);

it was working for you when the else {} part was un-commented  because you
are using \n in this statement
//printf( %d - %d \n , tmp[i], count); -- if you remove \n from here
then same problem will be reproduced


On Mon, Oct 29, 2012 at 12:47 PM, Rahul Kumar Patle 
patlerahulku...@gmail.com wrote:

 can anyone explain the reason for weird output producing by this code..
 it is giving output hello many time 30 but as code's logic it should
 print only 9 time
 it runs correctly when i comment out statements inside else{}
 thanks in advance

 #includestdio.h
 #includestdlib.h
 int count = 0;
 main()
 {
 int tmp[10] , i;
 int n = 0;
 for(i=0;i9;i++)
 {
 tmp[i]=fork();
 if(tmp[i]0)
 break;
 else
 {
 //count++;
 printf(Hello);
 //printf( %d - %d \n , tmp[i], count);
 }
 }
 }

 --
 Thanks and Regards:
 Rahul Kumar Patle
 M.Tech, School of Information Technology
 Indian Institute of Technology, Kharagpur-721302, 
 Indiahttp://www.iitkgp.ac.in/
 Mobile No: +91-8798049298, +91-9424738542
 Alternate Email: rahulkumarpa...@hotmail.com
 [image: 
 Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
 [image: Twitter] https://twitter.com/rahulkumarpatle
 https://www.facebook.com/rkpatle

  --
 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] Ternary operators

2012-10-30 Thread Tamanna Afroze
sorry for my last post, i didn't look carefully at the code. I think
without bracket the ternary expression is incomplete, that's why; first
code doesn't compile correctly.


On Wed, Oct 31, 2012 at 9:51 AM, Tamanna Afroze afroze...@gmail.com wrote:

 both codes are same. Where is the difference?


-- 
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.