Re: [algogeeks] Unique characters in a string

2011-07-25 Thread kashish jain
@reynald : I think your code takes care of only 32 ascii characters...and
not 256

On Sat, Jul 23, 2011 at 10:07 AM, keyan karthi keyankarthi1...@gmail.comwrote:

 yup tat should work fine :) :)


 On Sat, Jul 23, 2011 at 10:03 AM, rajeev bharshetty 
 rajeevr...@gmail.comwrote:

 Use Quick sort to sort the characters of a string (qsort is inplace
 sorting ) then check for consecutive characters in the array,  if they are
 same then the string is not unique else unique .(use builtin qsort in C .)
 No additional data structure is used ... What do u think of this guys ??

 On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:

 Implement an algorithm to determine if a string has all unique
 characters. What if you can not use additional data structures?

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc


  --
 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] Unique characters in a string

2011-07-25 Thread UTKARSH SRIVASTAV
please write your logicnot able to understand your
code..

On Sat, Jul 23, 2011 at 12:12 AM, Reynald Suz reynaldsus...@gmail.comwrote:

 This code works perfectly. Try out with different test data.
 int main()
 {
 //char str[]=qwertyuioplkjhgfdsazxcvbnm;
 char str2[] = qwertyquejolpd;
 int val, i;
 int len = strlen(str);
 int unique=1;
 int checker=0;
 for(=0;ilen;i++)
 {
val = str[i]-'a';
   if( (checker  (1val))  0 )
   {
  printf(\nNo, there aren't unique.);
  unique=0;
  break;
   }
checker |= (1val);
 }
 if(unique==1)
  printf(\nUnique charaters.);
 return 1;
 }


 On Sat, Jul 23, 2011 at 12:18 PM, rajeev bharshetty 
 rajeevr...@gmail.comwrote:

 @Victor : Counting sort uses extra data structures to maintain the count
 and the output array , so it is not viable I think ?? what say ??


 On Sat, Jul 23, 2011 at 11:04 AM, Victor Manuel Grijalva Altamirano 
 kavic1.mar...@gmail.com wrote:

 Use a type of counting sort with ascii


 2011/7/22 SkRiPt KiDdIe anuragmsi...@gmail.com

 Use 8 mask integers or 4 LL to cover the complete ascii range.

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




 --
 Victor Manuel Grijalva Altamirano
 Universidad Tecnologica de La Mixteca

  --
 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
 Rajeev N B http://www.opensourcemania.co.cc


  --
 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
 Reynald Reni
 Masters in Software Engineering
 CIT - India

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




-- 
*UTKARSH SRIVASTAV
CSE-3
B-Tech 2nd Year
@MNNIT 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] Unique characters in a string

2011-07-23 Thread rajeev bharshetty
@Victor : Counting sort uses extra data structures to maintain the count and
the output array , so it is not viable I think ?? what say ??

On Sat, Jul 23, 2011 at 11:04 AM, Victor Manuel Grijalva Altamirano 
kavic1.mar...@gmail.com wrote:

 Use a type of counting sort with ascii


 2011/7/22 SkRiPt KiDdIe anuragmsi...@gmail.com

 Use 8 mask integers or 4 LL to cover the complete ascii range.

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




 --
 Victor Manuel Grijalva Altamirano
 Universidad Tecnologica de La Mixteca

  --
 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
Rajeev N B http://www.opensourcemania.co.cc

-- 
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] Unique characters in a string

2011-07-23 Thread keyan karthi
yup tat should work fine :) :)

On Sat, Jul 23, 2011 at 10:03 AM, rajeev bharshetty rajeevr...@gmail.comwrote:

 Use Quick sort to sort the characters of a string (qsort is inplace sorting
 ) then check for consecutive characters in the array,  if they are same then
 the string is not unique else unique .(use builtin qsort in C .) No
 additional data structure is used ... What do u think of this guys ??

 On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:

 Implement an algorithm to determine if a string has all unique
 characters. What if you can not use additional data structures?

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc


  --
 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] Unique characters in a string

2011-07-23 Thread Reynald Suz
This code works perfectly. Try out with different test data.
int main()
{
//char str[]=qwertyuioplkjhgfdsazxcvbnm;
char str2[] = qwertyquejolpd;
int val, i;
int len = strlen(str);
int unique=1;
int checker=0;
for(=0;ilen;i++)
{
   val = str[i]-'a';
  if( (checker  (1val))  0 )
  {
 printf(\nNo, there aren't unique.);
 unique=0;
 break;
  }
   checker |= (1val);
}
if(unique==1)
 printf(\nUnique charaters.);
return 1;
}


On Sat, Jul 23, 2011 at 12:18 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

 @Victor : Counting sort uses extra data structures to maintain the count
 and the output array , so it is not viable I think ?? what say ??


 On Sat, Jul 23, 2011 at 11:04 AM, Victor Manuel Grijalva Altamirano 
 kavic1.mar...@gmail.com wrote:

 Use a type of counting sort with ascii


 2011/7/22 SkRiPt KiDdIe anuragmsi...@gmail.com

 Use 8 mask integers or 4 LL to cover the complete ascii range.

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




 --
 Victor Manuel Grijalva Altamirano
 Universidad Tecnologica de La Mixteca

  --
 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
 Rajeev N B http://www.opensourcemania.co.cc


  --
 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
Reynald Reni
Masters in Software Engineering
CIT - India

-- 
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] Unique characters in a string

2011-07-22 Thread Reynald
Implement an algorithm to determine if a string has all unique
characters. What if you can not use additional data structures?

-- 
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] Unique characters in a string

2011-07-22 Thread keyan karthi
u can use an integer as a bit mask to do this... by setting the
 alphabet-'a' th bit, and checking the same..

On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:

 Implement an algorithm to determine if a string has all unique
 characters. What if you can not use additional data structures?

 --
 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] Unique characters in a string

2011-07-22 Thread Ankur Khurana
what if cahrs are in ascii code range and not just characters. Any solution
for that ?

On Sat, Jul 23, 2011 at 9:57 AM, keyan karthi keyankarthi1...@gmail.comwrote:

 u can use an integer as a bit mask to do this... by setting the
  alphabet-'a' th bit, and checking the same..


 On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:

 Implement an algorithm to determine if a string has all unique
 characters. What if you can not use additional data structures?

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




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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] Unique characters in a string

2011-07-22 Thread rajeev bharshetty
Use Quick sort to sort the characters of a string (qsort is inplace sorting
) then check for consecutive characters in the array,  if they are same then
the string is not unique else unique .(use builtin qsort in C .) No
additional data structure is used ... What do u think of this guys ??

On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:

 Implement an algorithm to determine if a string has all unique
 characters. What if you can not use additional data structures?

 --
 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
Rajeev N B http://www.opensourcemania.co.cc

-- 
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] Unique characters in a string

2011-07-22 Thread SkRiPt KiDdIe
Use 8 mask integers or 4 LL to cover the complete ascii range.

-- 
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] Unique characters in a string

2011-07-22 Thread Victor Manuel Grijalva Altamirano
Use a type of counting sort with ascii

2011/7/22 SkRiPt KiDdIe anuragmsi...@gmail.com

 Use 8 mask integers or 4 LL to cover the complete ascii range.

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




-- 
Victor Manuel Grijalva Altamirano
Universidad Tecnologica de La Mixteca

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