Re: [algogeeks] Openings in Mentor Graphics,Noida Location

2015-11-16 Thread saurabh singh
Banned for spamming.
Again a request to the members to post algorithm related queries. Stuck in
some programming problem? Post it here. Not understanding some algorithm?
Post it here. Found an interesting problem? Post it.

On Tue, Nov 17, 2015 at 10:04 AM Ashish kumar Jain 
wrote:

> Anybody interested to join Mentor Graphics Noida having 1-10 years of
> experience in C/C++/DS/Algo can forward his/her resume to me.
>
> Please understand that the opening needs to be closed urgently.So,Hurry up.
>
> Note: Please ignore if inappropriate for this forum.
>
>
> --
> Regards,
> Ashish
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Opening in Oracle IDC: Having experience in C/C++ 1.5 to 3 yr

2015-11-16 Thread saurabh singh
Banned for spamming.
Again a request to the members to post algorithm related queries. Stuck in
some programming problem? Post it here. Not understanding some algorithm?
Post it here. Found an interesting problem? Post it

On Mon, Nov 16, 2015 at 8:56 AM shashi kant  wrote:

> HI, thanks for letting me know ...
>
> *Shashi Kant *
> *"Think positive and find fuel in failure"*
>
> *Senior Member technical Staff*
> *Oracle India Pvt Ltd*
> http://thinkndoawesome.blogspot.com/
>
> On Mon, Nov 16, 2015 at 4:31 AM, Shachindra A C 
> wrote:
>
>> You're not supposed to post job ads over here. Please help keeping the
>> group clean.
>>
>> On Wed, Nov 11, 2015 at 7:55 PM, shashi kant 
>> wrote:
>>
>>> hi,
>>>
>>> *Note:* if an inappropriate mail ..please do ignore
>>>
>>> Opening in Oracle IDC: Having experience in C/C++ 1.5 to 3 yr ..mail
>>> your resume to me
>>>
>>>
>>>
>>> Regards,
>>> *Shashi Kant *
>>> *"Think positive and find fuel in failure"*
>>>
>>> *Senior Member technical Staff*
>>> *Oracle India Pvt Ltd*
>>> http://thinkndoawesome.blogspot.com/
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>
>>
>>
>>
>> --
>> Regards,
>> Shachindra A C
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


[algogeeks] Re: [BANNED!!!] Urgent need Lead - Java Developer in Atlanta, GA

2015-11-02 Thread saurabh singh
FYI, have banned this user and several others who mistook this group for a
recruitment platform. Can we revive the legacy of this group again?

On Mon, Nov 2, 2015 at 11:36 PM Shaik Asif  wrote:

> Hi Partner,
>
> This is Shaik from Deegit Inc. Partner find the below requirement for your
> consultants. If there are available. Please get back to me ASAP on
> sh...@deegit.com
>
> *WE ARE LOOKING FOR 10+ YEAR'S RESUME'S*
>
> *Position: Lead - Java Developer *
>
> Location: Atlanta, GA 30301
>
> Duration: Long Term
>
>
>
> *Required skills: *
>
> · Experience in Unemployment Insurance
>
> · Core java, Spring MVC, SQL Transactions Annotations
>
> · experience with systems consulting, development and systems
> engineering in software projects technical design and development of Java
> based systems
>
> · Experience developing systems within the framework and
> governance of a well-defined Systems Engineering Life Cycle (SELC)
>
> · Experience in the role of systems consultant on projects of
> high complexity that typically have multiple concurrent and related
> activities
>
> · Delivery role handling complex Java projects
>
> · demonstrated technical experience with:
>
> · Java, JSP/Servlets, XML,
>
> · SOAP, Struts/Spring/Hibernate
>
> · Knowledge of Design Patterns, UML and Web Services.
>
> · Knowledge of Weblogic.
>
> · Understanding of SQL queries, Stored procedure, DB Design etc.
>
> · Knowledge of Junit Framework and Testing Techniques,
> Code-Coverage using java based tools like Eclipse
>
> Best Regards,
>
> ___
>
>
>
> Shaik | Deegit Inc |
>
> 1900 East Golf Rd., Suite 925 | Schaumburg, IL 60173 |
>
> Ph: 847.440.2436 ext - 358 | Fax: 847.330.1987
>
> sh...@deegit.com | www.deegit.com |
>
>
>
> “GSA Approved - GS-35F-0405V”
>
> "Certified Minority Business Enterprise (MBE)"
>
> "Winner - Deloitte Technology Fast 500 for 2008"
>
> "Winner - Inc. 5000 fastest growing firm for 2008"
>
> "Winner - Inc. 5000 fastest growing firm for 2009"
>
>
>
> "Right Person for the Right Job in the Right Time"
>
>
>
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from any
> computer.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Re: [BANNED!!!] Urgent need Lead - Java Developer in Atlanta, GA

2015-11-02 Thread saurabh singh
Yes, I would like that. I am sure about other admins, but I am guilty of
ignoring mails on the group. I am finding it hard to manage things between
job, other interests and google groups that I own/moderate. People who want
to volunteer to moderate this group, please reply (unicast to me,
*avoid reply all).*
Obviously also post stuff proactively so that the discussions can resume. :)

On Tue, Nov 3, 2015 at 12:02 AM Deshank Baranwal <desh...@gmail.com> wrote:

> I guess we need new admins who can actively moderate the group.
>
>
> On Mon, Nov 2, 2015 at 6:30 PM, Shachindra A C <sachindr...@gmail.com>
> wrote:
>
>> Well, you need to ban a whole lot more people.
>>
>> On Mon, Nov 2, 2015 at 10:16 AM, saurabh singh <saurab...@gmail.com>
>> wrote:
>>
>>> FYI, have banned this user and several others who mistook this group for
>>> a recruitment platform. Can we revive the legacy of this group again?
>>>
>>>
>>> On Mon, Nov 2, 2015 at 11:36 PM Shaik Asif <shaik.deegi...@gmail.com>
>>> wrote:
>>>
>>>> Hi Partner,
>>>>
>>>> This is Shaik from Deegit Inc. Partner find the below requirement for
>>>> your consultants. If there are available. Please get back to me ASAP on
>>>> sh...@deegit.com
>>>>
>>>> *WE ARE LOOKING FOR 10+ YEAR'S RESUME'S*
>>>>
>>>> *Position: Lead - Java Developer *
>>>>
>>>> Location: Atlanta, GA 30301
>>>>
>>>> Duration: Long Term
>>>>
>>>>
>>>>
>>>> *Required skills: *
>>>>
>>>> · Experience in Unemployment Insurance
>>>>
>>>> · Core java, Spring MVC, SQL Transactions Annotations
>>>>
>>>> · experience with systems consulting, development and systems
>>>> engineering in software projects technical design and development of Java
>>>> based systems
>>>>
>>>> · Experience developing systems within the framework and
>>>> governance of a well-defined Systems Engineering Life Cycle (SELC)
>>>>
>>>> · Experience in the role of systems consultant on projects of
>>>> high complexity that typically have multiple concurrent and related
>>>> activities
>>>>
>>>> · Delivery role handling complex Java projects
>>>>
>>>> · demonstrated technical experience with:
>>>>
>>>> · Java, JSP/Servlets, XML,
>>>>
>>>> · SOAP, Struts/Spring/Hibernate
>>>>
>>>> · Knowledge of Design Patterns, UML and Web Services.
>>>>
>>>> · Knowledge of Weblogic.
>>>>
>>>> · Understanding of SQL queries, Stored procedure, DB Design
>>>> etc.
>>>>
>>>> · Knowledge of Junit Framework and Testing Techniques,
>>>> Code-Coverage using java based tools like Eclipse
>>>>
>>>> Best Regards,
>>>>
>>>> ___
>>>>
>>>>
>>>>
>>>> Shaik | Deegit Inc |
>>>>
>>>> 1900 East Golf Rd., Suite 925 | Schaumburg, IL 60173 |
>>>>
>>>> Ph: 847.440.2436 ext - 358 | Fax: 847.330.1987
>>>>
>>>> sh...@deegit.com | www.deegit.com |
>>>>
>>>>
>>>>
>>>> “GSA Approved - GS-35F-0405V”
>>>>
>>>> "Certified Minority Business Enterprise (MBE)"
>>>>
>>>> "Winner - Deloitte Technology Fast 500 for 2008"
>>>>
>>>> "Winner - Inc. 5000 fastest growing firm for 2008"
>>>>
>>>> "Winner - Inc. 5000 fastest growing firm for 2009"
>>>>
>>>>
>>>>
>>>> "Right Person for the Right Job in the Right Time"
>>>>
>>>>
>>>>
>>>> The information transmitted is intended only for the person or entity
>>>> to which it is addressed and may contain confidential and/or privileged
>>>> material. Any review, retransmission, dissemination or other use of, or
>>>> taking of any action in reliance upon, this information by persons or
>>>> entities other than the intended recipient is prohibited. If you received
>>>> this in error, please contact the sender and delete the material from any
>>&g

RE: [algogeeks] Yo! Help me make a Music Video

2014-12-28 Thread saurabh singh
Nope. Forwarding this mail to a group with over 1 k members is definitely 
begging. It's shameless begging as it can get. No,Didn't bother to open the 
link. Also banning you from the group. 

-Original Message-
From: Shrey Choudhary choudharyshre...@gmail.com
Sent: ‎12/‎28/‎2014 4:52 PM
To: a.mat...@accenture.com a.mat...@accenture.com; Aadhaar Sharma 
aadhaar.r.sha...@gmail.com; Aakanksha Raghav aakanksha.rag...@gmail.com; 
abhijitcomplete . abhijitcompl...@gmail.com; Abhilash Rajpoot 
abhilashrajpoot.n...@gmail.com; Abhinav kapur abhinav.nit...@gmail.com; 
abhinay.mo...@tctinfotech.com abhinay.mo...@tctinfotech.com; 
admin.off...@oberoigroup.com admin.off...@oberoigroup.com; Airtel 
Presence airtelprese...@airtel.in; Akash Bajaj aks...@gmail.com; Akhil 
Saraf saraf.akhi...@gmail.com; algogeeks@googlegroups.com 
algogeeks@googlegroups.com; ami.ta...@gmail.com ami.ta...@gmail.com; 
Amit Goel amitgoel@gmail.com; Amit Kumar Singh 
amit.si...@99acres.com; Anjali Gupta anjaligupta@gmail.com; ankit 
malik ankitmal...@gmail.com; ankit verma a_verm...@yahoo.co.in; Ankit 
Yadav ankityadav27...@gmail.com; antriksh.c...@nic.in 
antriksh.c...@nic.in; Anurag Dak anurag...@gmail.com; Anurag Kundu 
anurag13ku...@gmail.com; anushree bhatt 1594anush...@gmail.com; aparna 
roy tnahps...@gmail.com; arjun singh arjun107...@gmail.com; Arpan 
Saxena arpan.sax...@naukri.com; arushi paliwal 
paliwalarush...@gmail.com; atam prakash atam...@gmail.com; Bhumika 
Sachdeva swtmit...@gmail.com; cyberbyte.literat...@gmail.com 
cyberbyte.literat...@gmail.com; danish.shab...@accenture.com 
danish.shab...@accenture.com; deep...@proteaminc.com 
deep...@proteaminc.com; Deepali Garg nikki.deep...@gmail.com; 
dhruv_mech...@yahoo.co.in dhruv_mech...@yahoo.co.in; ekta dwivedy 
ektadwiv...@gmail.com; fansofn...@gmail.com fansofn...@gmail.com; Gaurav 
Goel gaurav16g...@gmail.com; Gaurav Sharma gaurav07101...@gmail.com; 
Gaurav Walia gauravwalia2...@gmail.com; gnee...@amazon.com 
gnee...@amazon.com; Helios NITK helios12.n...@gmail.com; 
helios.nitk2...@gmail.com helios.nitk2...@gmail.com; Himsa Narzari 
himsa.narz...@gmail.com; i...@chillomrecordsindia.com 
i...@chillomrecordsindia.com; infotechnit...@googlegroups.com 
infotechnit...@googlegroups.com; intern...@tctinfotech.com 
intern...@tctinfotech.com; invest...@naukri.com invest...@naukri.com; 
Jasmine Gambhir gambhir.jasm...@gmail.com; Jitender Kumar 
jkjitenderkum...@gmail.com; jitenderchha...@gmail.com 
jitenderchha...@gmail.com; kamal khandelwal kkhandel...@gmail.com; 
Kanika Bansal kanikaban...@drishti-soft.com; Kashish Mittal 
kashishmitta...@gmail.com; khurana.prach...@yahoo.in 
khurana.prach...@yahoo.in; kriti.j...@99acres.com kriti.j...@99acres.com; 
Kunal Kapoor kunal.kap...@exlservice.com; Kunsana Tab 
kunalkapoo...@yahoo.com; larry.guill...@rackspace.com 
larry.guill...@rackspace.com; LOKESH GUPTA lokeshgupt...@gmail.com; 
Madhuresh Srivastava madhures...@gmail.com; Mamta Kayest 
mamta1987...@gmail.com; Manish Dhall manishdhal...@gmail.com; 
manishkam...@rediffmail.com manishkam...@rediffmail.com
Subject: [algogeeks] Yo! Help me make a Music Video

Waddup guys,

Hope everything is fine at your end. So this is a personal mail, I'm sending 
out. I've recently started my IndieGogo Crowdfunding Campaign for a hip hop 
music video. I'm now taking my passion for rapping to another level. It's just 
that I'm little short of funds. I need around 1000 to 1400 $ to come out with a 
good concept music video and hire promoters to do the same. 


The details of  the campaign can be found at this link. 
https://www.indiegogo.com/projects/indian-hiphop-single-music-video/x/9462122


If you all believe in me, donate a dollar or two; that's mere ~Rs 120. People 
smoke this much amount in one day. 




PS: If you think am begging for money, then please you don't have to pay 
anything. Don't even open the link and you can happily remove me from your 
circle. Because am a friend asking for help from friends . Nothing else.






Regards
Shrey Choudhary

Mobile: +919953029023



The future belongs to those who believe in the beauty of their dreams - 
Eleanor Roosevelt

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] C++ initialization list

2014-09-28 Thread saurabh singh
Here you go
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3337.pdf
The c++ standard itself. Refer to section 8.5.4 page no. 213.
Looks like even this int a[10] = {2} is not guaranteed to initialize all
the elements of the array. Sure gcc provides this but then it becomes a
compiler specific thing. The language doesn't advocates it.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

On Sun, Sep 28, 2014 at 3:47 PM, sagar sindwani sindwani.sa...@gmail.com
wrote:

 Thanks Deepak and Rahul for the reply.

 Do you guys have any standard document or any standard book which defines
 this?  I totally agree with these answers but I don't have any formal
 written text.

 In my example 1, the object is on stack and this lead to a1[0].z to be
 un-initialized. But as the specified in example 2, Why every element of arr
 is initialized, it is also on the stack ? Any source to answer this
 question ?

 Thanks
 Sagar



 On Sun, Sep 28, 2014 at 2:26 PM, Rahul Vatsa vatsa.ra...@gmail.com
 wrote:


 http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly

 On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg deepakgarg...@gmail.com
 wrote:

 Hi

 In example 1, member z will have a garbage value (i.e. 0 in your case )

 Thanks
 Deepak
 On Sep 28, 2014 11:29 AM, sagar sindwani sindwani.sa...@gmail.com
 wrote:

 I am working on How compilers handle initialization list. I came across
 a case where I am not sure what should be the compiler behaviour.

 *Example 1:-*

 #include iostream

 class A
 {
 public:
 int x,y,z;
 };

 int main()
 {
 A a1[2] =
 {
 { 1,2 },
 { 3,4 }
 };

 std::cout  a1[0].z is   a1[0].z  std::endl;

 return 0;
 }

 In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0
 or garbage value, I am not sure on that.

 I tried lot of books and some documents , no where I found what C++
 says for initialization of class objects.

 You can find handling of below case in almost every book.

 *Example 2:- *

 int arr[6] = {0};

 In Example 2,  compilers will auto-fill all members with 0. It is
 mentioned in books. But when it comes to User-defined datatypes nothing is
 mentioned.


 Please share your thoughts on this. If you find any document related to
 this, please share it as well.

 Thanks
 Sagar

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to algogeeks+unsubscr...@googlegroups.com.

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to algogeeks+unsubscr...@googlegroups.com.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to algogeeks+unsubscr...@googlegroups.com.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to algogeeks+unsubscr...@googlegroups.com.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Solving equation

2014-01-27 Thread saurabh singh
^ No its not invalid. It just represents an equation with infinitely many
correct solutions depending on the domain of x.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com


On Mon, Jan 27, 2014 at 4:21 PM, Amol Sharma amolsharm...@gmail.com wrote:

 i din't get ur question.

 isn't the equation *(x - 7) + 7 = (x + 1) - 5*  invalid ?

 --
 Thanks and Regards,
 Amol Sharma



 On Wed, Jan 15, 2014 at 3:34 AM, Arpit Sood soodfi...@gmail.com wrote:

 Equivalent to solving an infix expression using stack with a pair (first
 variable, second constant) as the element


 On Sat, Jan 11, 2014 at 6:50 AM, atul anand atul.87fri...@gmail.comwrote:

 Hello,

 How to solve an equation with one unknown variable ?
 operator allowed are : + , -

 for eg .  input could be :-
 x + ( 5 + 4 ) = 6
 (x - 7) + 7 = (x + 1) - 5

 If operator also allows  *  (multiply) , then what change in algorithm
 is required.

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to algogeeks+unsubscr...@googlegroups.com.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to algogeeks+unsubscr...@googlegroups.com.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to algogeeks+unsubscr...@googlegroups.com.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] perfect square condition checking....

2012-12-27 Thread saurabh singh
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com


On Sun, Dec 23, 2012 at 9:07 PM, Anil Sharma anilsharmau...@gmail.comwrote:

 no matter how much large number is


still,how large?If it fits in long long int then using binary search we can
check this is O(log n) time.

-- 




Re: [algogeeks] Regex tester

2012-12-23 Thread saurabh singh
If you need to implement this for some project then python and java have a
very nice library


Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com


On Sun, Dec 23, 2012 at 7:48 PM, shady sinv...@gmail.com wrote:


 http://stackoverflow.com/questions/13144590/to-check-if-two-strings-match-with-alphabets-digits-and-special-characters

 any solution for this. we need to implement such regex
 tester

 some complex cases :
 *string** regex *   -   * status*
 *
 *
 reesd   re*.d  -   match
 re*eed reeed -   match

 can some one help with this ?

  --




-- 




Re: [algogeeks] how does this code achieve SIGSEGV

2012-12-21 Thread saurabh singh
**p; *
Explanation: By default C thinks everything is an int. So p is a global
variable of type *pointer to an int.*Now like other global variables it is
very very very very likely  that the compiler will associate p with an
address that is *0.*Or in terms of pointers it is  *NULL.* That is
printf(%d\n,p) should give 0.
**p=0;*
*
*
What happens when you do **(some_ptr)? *The address stored by some_ptr is
referred to. So when we try to do **p=0 the address pointed by p is
referred,which is NULL,and by the law of the land trying to read/write from
memory with address NULL is sin. *So you get segmentation fault.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com


On Sat, Dec 22, 2012 at 10:52 AM, Saurabh Paliwal 
saurabh.paliwa...@gmail.com wrote:

 I am afraid both of you are incorrect..
 1. since the code modified by you will compile but give sigsegv anyway.
 2. The statement  *p = 0;  has nothing to do with the  random address
 you are talking about.


 On Mon, Dec 17, 2012 at 7:25 PM, Prakhar Jain jprakha...@gmail.comwrote:

 You are initialising random memory address with 0, which OS doesn't allow.

 On 12/17/12, Shubham Sandeep s.shubhamsand...@gmail.com wrote:
  how does this code achieve SIGSEGV
  code:
   *p;main(){*p=0;}
 
  --
  Regards,
  SHUBHAM SANDEEP
  IT 3rd yr.
  NIT ALD.
 
  --
 
 
 


 --
 --
 Prakhar Jain
 IIIT Allahabad
 B.Tech IT 4th Year
 Mob no: +91 9454992196
 E-mail: rit2009...@iiita.ac.in
   jprakha...@gmail.com

 --





 --
  -Saurabh Paliwal

B-Tech. Comp. Science and Engg.

IIT ROORKEE

 --




-- 




Re: [algogeeks] Re: Adobe Interview Question

2012-12-13 Thread saurabh singh
^ *Exactly,* Things are the *same all around the globe *in terms of
hiring procedure for programming positions. However I don't understand *this
is India  *part?
Kindly reply only *when you think you are contributing something to the
community.*

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Dec 13, 2012 at 10:27 AM, rahul rahulr...@gmail.com wrote:

 @don , becoz this is India...and shit happens everywhere


 On Wed, Dec 12, 2012 at 11:48 PM, Don dondod...@gmail.com wrote:

 I dislike interview questions which place arbitrary restrictions on
 the solver.
 It may be a good puzzle, but it's not a good interview question.

 Print the numbers 1 to 100 without using a loop.

 Why would you want to do that?

 Divide a number by 5 without using the divide operator.

 Again, why? Interview questions shouldn't be about silly little
 tricks, but about showing that you can do a real-world job.

 Don

 On Dec 11, 10:23 pm, saurabh singh saurab...@gmail.com wrote:
  I would have replied back with I am doing it with C programming language
  only. the read function that we use is not an actual system call. It
  is a *wrapper
  to a system call*. Any other function that we use usually ends up in
  calling some system call. The actual system call is called by low level
  routines.
  If he still disagreed I would have given him this solution:
 
  #includestdio.h
  int main()
  {
  int ch;
  while((ch=getchar())!=-1) putchar(ch);
  return 0;
 
  }
 
  Would have run this as *./a.out  file_to_read*
  *
  *
  If he still disagreed I would have walked out :P
 
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Tue, Dec 11, 2012 at 11:23 PM, manish untwal 
 manishuntw...@gmail.comwrote:
 
 
 
 
 
 
 
   i answered with the...system call too..but he said...do it in C
   programming language only don't use...system call here!!
 
   On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh saurab...@gmail.com
 wrote:
 
   stdin is a file pointer.
   freopen returns a file pointer..
   I suggest using read system call.
 
   For the second question it would be simply
   (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)
 
   However this will also contains permutations which begin with 0. So
   subtract the number of permutations that begin with 0 from this
 number.
 
   Since any factorial in the denominator part will be less than or
 equal to
   (len)! we can calculate and store them while calculating len! Hence
 the
   overall operation will take O(len) time which would be O(log n)
 where n is
   the number.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Tue, Dec 11, 2012 at 11:02 AM, amrit harry 
 dabbcomput...@gmail.comwrote:
 
   1st:
 
   freopen(filename,r,stdin);
 
   while(scanf(%s,str)!=-1)
   {
   printf(%s\n,str);
   }
 
   On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
 manishuntw...@gmail.comwrote:
 
   I gave this interview in August this year, two of the question i
 was
   not able to answer properly
   1) how to print the content of file in C without using the file
 pointer.
   2) count the total number of permutation of a number in order O(n)
 
   --
 
   --
   Thanks  Regards
   Amritpal singh
 
--
 
--
 
   --
   With regards,
   Manish kumar untwal
   Indian Institute of Information Technology
   Allahabad (2009-2013 batch)
 
--

 --



  --




-- 




Re: [algogeeks] Adobe Interview Question

2012-12-11 Thread saurabh singh
stdin is a file pointer.
freopen returns a file pointer..
I suggest using read system call.

For the second question it would be simply
(len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)

However this will also contains permutations which begin with 0. So
subtract the number of permutations that begin with 0 from this number.

Since any factorial in the denominator part will be less than or equal to
(len)! we can calculate and store them while calculating len! Hence the
overall operation will take O(len) time which would be O(log n) where n is
the number.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Dec 11, 2012 at 11:02 AM, amrit harry dabbcomput...@gmail.comwrote:

 1st:

 freopen(filename,r,stdin);

 while(scanf(%s,str)!=-1)
 {
 printf(%s\n,str);
 }


 On Sun, Dec 9, 2012 at 3:22 PM, manish untwal manishuntw...@gmail.comwrote:

 I gave this interview in August this year, two of the question i was not
 able to answer properly
 1) how to print the content of file in C without using the file pointer.
 2) count the total number of permutation of a number in order O(n)

 --






 --
 Thanks  Regards
 Amritpal singh

  --




-- 




Re: [algogeeks] Adobe Interview Question

2012-12-11 Thread saurabh singh
I would have replied back with I am doing it with C programming language
only. the read function that we use is not an actual system call. It
is a *wrapper
to a system call*. Any other function that we use usually ends up in
calling some system call. The actual system call is called by low level
routines.
If he still disagreed I would have given him this solution:

#includestdio.h
int main()
{
int ch;
while((ch=getchar())!=-1) putchar(ch);
return 0;
}

Would have run this as *./a.out  file_to_read*
*
*
If he still disagreed I would have walked out :P


Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Dec 11, 2012 at 11:23 PM, manish untwal manishuntw...@gmail.comwrote:

 i answered with the...system call too..but he said...do it in C
 programming language only don't use...system call here!!

 On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh saurab...@gmail.comwrote:

 stdin is a file pointer.
 freopen returns a file pointer..
 I suggest using read system call.

 For the second question it would be simply
 (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)

 However this will also contains permutations which begin with 0. So
 subtract the number of permutations that begin with 0 from this number.

 Since any factorial in the denominator part will be less than or equal to
 (len)! we can calculate and store them while calculating len! Hence the
 overall operation will take O(len) time which would be O(log n) where n is
 the number.

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Tue, Dec 11, 2012 at 11:02 AM, amrit harry dabbcomput...@gmail.comwrote:

 1st:

 freopen(filename,r,stdin);

 while(scanf(%s,str)!=-1)
 {
 printf(%s\n,str);
 }


 On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
 manishuntw...@gmail.comwrote:

 I gave this interview in August this year, two of the question i was
 not able to answer properly
 1) how to print the content of file in C without using the file pointer.
 2) count the total number of permutation of a number in order O(n)

 --






 --
 Thanks  Regards
 Amritpal singh

  --




  --






 --
 With regards,
 Manish kumar untwal
 Indian Institute of Information Technology
 Allahabad (2009-2013 batch)

  --




-- 




Re: [algogeeks] Data structure and algorithm made easy by narasimha karumanchi

2012-12-06 Thread saurabh singh
itti achi hai to khareed lo jake..yaha na milegi :P
( If it is that good,go buy it.You won't get it here)


*No more posts on this thread.And please this is not torrent. Please dont
post such requests in future*

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Dec 7, 2012 at 10:37 AM, pradeepiiita pradeep16051...@gmail.comwrote:


- Any 1 having* Data structure and algorithm made easy by narasimha
karumanchi* ?? plz forward me d full e book ... :)

  --




-- 




Re: [algogeeks] VIDEO STREAMING

2012-11-24 Thread saurabh singh
You are trying the wrong place.try stackoverflow.the best place to go
when ur ass is on fire. :p

On 11/24/12, Prateek Gupta prateek.22gu...@gmail.com wrote:
 @kartik +1:P :P

 PS : pardon the pun.


 On Sat, Nov 24, 2012 at 11:42 AM, Kartik Sachan
 kartik.sac...@gmail.comwrote:


 hey anybody has any idea about video streaming using vlcj lib ??


 --

 *WITH REGARDS,

 *KARTIK SACHAN
  B.Tech. Final Year
 Computer Science And Engineering
 Motilal Nehru National Institute of Technology,Allahabad
 Phone No: +91-9451012943
 E-mail: kartik.sac...@gmail.com


  --




 --





-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 




Re: [algogeeks] Check if a binary tree is Binary Search Tree or not.

2012-11-09 Thread saurabh singh
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Nov 9, 2012 at 10:00 AM, atul anand atul.87fri...@gmail.com wrote:

 @saurabh : correct..yes if you are considering recursive approach , so it
 will take O(n) space stack.But same can be done using Morris traversal then
 space will be constant.


-- 
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] Check if a binary tree is Binary Search Tree or not.

2012-11-08 Thread saurabh singh
^ To perform inorder traversal in  a binary tree without using stack space
the tree must be mutable. In other cases as far as I can think the space
complexity should be asymptotically O(n) where n are the number of nodes.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Nov 7, 2012 at 10:09 AM, atul anand atul.87fri...@gmail.com wrote:

 @vaibhav : by not using extra space...i guess you mean that you were not
 allowed to use one extra pointer.bcozz space complexity will remain
 constant for inorder approch.

 On Tue, Nov 6, 2012 at 1:07 AM, vaibhav shukla vaibhav200...@gmail.comwrote:

 yes ofcourse... dats the easiest i suppose...
 but in one of my interviews, i told this approach, but was then asked not
 to use space (which i was ,to store inorder)
 So for such cases, you must try other approaches as well. (DO
 inorder,keep track of previously visited node and compare it with current
 node for value greater,or less accordingly.)


 On Tue, Nov 6, 2012 at 12:34 AM, shady sinv...@gmail.com wrote:

 Hi,
 Can we check this by just doing an inorder traversal, and then checking
 if it is in increasing order or not ?

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




 --
 best wishes!!
  Vaibhav

  --
 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] Fork in c

2012-10-27 Thread saurabh singh
printf is line buffered. hence text1 remains in buffer when fork is
called.this is shared by both the child and the parent when fork is called.
Leaving the rest for u to conclude

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Oct 27, 2012 at 2:25 PM, CHIRANJEEV KUMAR
cse.chiranj...@gmail.comwrote:

 I think the output should be :

 text1text2
 text2




 On Sat, Oct 27, 2012 at 2:22 PM, rahul sharma rahul23111...@gmail.comwrote:

 int main()  {
 printf(text1);
 fork();
 printf(text2\n);
 return 0;  }

  the output  is:

 text1text2
 text1text2

 Please explain o/p

  --
 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] Fork in c

2012-10-27 Thread saurabh singh
Yup
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Oct 27, 2012 at 8:21 PM, rahul sharma rahul23111...@gmail.comwrote:

 text 1 remains in buffer...nowwhen child reaches print f.it prints
 oldbuffer+newdata...m i ryt???


 On Sat, Oct 27, 2012 at 4:07 PM, saurabh singh saurab...@gmail.comwrote:

 printf is line buffered. hence text1 remains in buffer when fork is
 called.this is shared by both the child and the parent when fork is called.
 Leaving the rest for u to conclude

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, Oct 27, 2012 at 2:25 PM, CHIRANJEEV KUMAR 
 cse.chiranj...@gmail.com wrote:

 I think the output should be :

 text1text2
 text2







 On Sat, Oct 27, 2012 at 2:22 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 int main()  {
 printf(text1);
 fork();
 printf(text2\n);
 return 0;  }

  the output  is:

 text1text2
 text1text2

 Please explain o/p

  --
 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] directi paper pattern

2012-08-02 Thread saurabh singh
Please stop this idiocity of  *me too,me too *
You can send personal mails to the author,why spam the group?

No More Posts on this thread.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] pls guy im need of a ebook named Data Structures and algorithms made easy details given below....

2012-07-20 Thread saurabh singh
Above users banned for violating group policy. NO MORE  POSTS ON THIS
THREAD.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Jul 20, 2012 at 11:39 PM, suresh kumar mahawar 
suresh.mahawar1...@gmail.com wrote:



 On Fri, Jul 20, 2012 at 11:02 PM, sarath prasath 
 prasathsar...@gmail.comwrote:

 Book: Data Structures And Algorithms Made Easy: Data Structure And
 Algorithmic Puzzles
 Author: Narasimha Karumanchi
  ISBN: 0615459811
 ISBN-13: 9780615459813, 978-0615459813
 Binding: Paperback
 Publishing Date: 2011
 Publisher: CareerMonk Publications
 Edition: 2ndEdition
 Number of Pages: 484
 Language: English


 pls guys if anyone having this book's pdf or something pls do share to my
 email.

 my email id is prasathsar...@gmail.com , suresh.mahawar1...@gmail.com
  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/-/HOSKfo0wvRAJ.
 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.




 --
 Suresh Kumar Mahawar,
 CSE,ISM Dhanbad

  --
 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] Anagram problem

2012-07-18 Thread saurabh singh
^sorting a string would be o(n^2logn) if u use q.sort.count sort would be
better.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra
vindhyachha...@gmail.comwrote:

 sort the list,sort the word(use quick sort(nlogn  time))- and den search
 using binary search(logn time)
 or we can evn do by hashing-hash the word,den for every word keep
 decreasing the counter,if the hash array is zero ,anagram,else reset the
 hash array for given input for the checking the next word.


 On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.comwrote:

 Assuming a preexisting list of 100 words, how would you efficiently see
 if a word received from input is an anagram of any of the 100 words?

 --
 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/-/5kuxjymYEc4J.
 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.




 --
 Vindhya Chhabra




  --
 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] A Coding Problem

2012-07-14 Thread saurabh singh
its from a running contest i believe.This is against the group policy as
well as against the ethics of programmers. The author of this post is
banned permanently from algogeeks. Kindly no more posts on this thread till
16th July (the date mentioned as end of contest in the given link).
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Jul 14, 2012 at 2:36 PM, Gobind Kumar Hembram
gobind@gmail.comwrote:


 Please visit this 
 linkhttp://www.techgig.com/codehire/ZSAssociates/problem/35.And
 help me in  solving this.
 --
 Thanks  Regards
 Gobind Kumar Hembram
 Contact no.-+91867450


  --
 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: [Google] Finds all the elements that appear more than n/3 times

2012-06-30 Thread saurabh singh
@above


 On Thursday, 28 June 2012 04:05:12 UTC+5:30, Navin Kumar wrote:


 Design an algorithm that, given a list of n elements in an array, finds
 all the elements that appear more than n/3 times in the list. The algorithm
 should run in linear time

 ( n =0 ).

 You are expected to use comparisons and achieve linear time. No 
 hashing/excessive
 space/ and don't use standard linear time deterministic selection algo.


 On Thursday, 28 June 2012 04:05:12 UTC+5:30, Navin Kumar wrote:


 Design an algorithm that, given a list of n elements in an array, finds
 all the elements that appear more than n/3 times in the list. The algorithm
 should run in linear time

 ( n =0 ).

 You are expected to use comparisons and achieve linear time. No
 hashing/excessive space/ and don't use standard linear time deterministic
 selection algo.


 On Thursday, 28 June 2012 04:05:12 UTC+5:30, Navin Kumar wrote:


 Design an algorithm that, given a list of n elements in an array, finds
 all the elements that appear more than n/3 times in the list. The algorithm
 should run in linear time

 ( n =0 ).

 You are expected to use comparisons and achieve linear time. No
 hashing/excessive space/ and don't use standard linear time deterministic
 selection algo.

  --
 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/-/0myz4OIStO8J.

 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] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread saurabh singh
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Jun 29, 2012 at 10:41 AM, raghavan M
peacelover1987...@yahoo.co.inwrote:

 Hi
 Question as in subject

 *No extra space (can use one extra space)-O(1) max
 *No order change allowed
 example:

 input : 1,-5,2,10,-100,-2
 output: -5,-10,-100,1,2

 input : -1,-5,10,11,15,-500,200,-10
 output : -1,-5,-10,-500,-10,10,11,15


 Thanks
 Raghavn

 --
 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] Switch doubt in C

2012-06-29 Thread saurabh singh
the cases are simple lables they have nothing to do with the flow of
program.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Jun 29, 2012 at 3:14 PM, adarsh kumar algog...@gmail.com wrote:

 Doubt, very trivial though:
 #includestdio.h
 int main()
 {
 int x=3;
 switch(x)
 {
  case 1:
 x=1;
 break;
  case 2:
 x=2;
 break;
  case 3:
 x=3;
 break;
  default:
  x=0;
  break;
  case 4:
 x=4;
 break;
 }
 printf(%d,x)
 return 0;
 }
 gives an output of 3. But,
 #includestdio.h
 using namespace std;
 int main()
 {
 int x=3;
 switch(x)
 {
  case 1:
 x=1;
  case 2:
 x=2;
  case 3:
 x=3;
  default:
  x=0;
  case 4:
 x=4;
 }
printf(%d,x);
 getch();
 return 0;
 }
 gives an output of 4.
 My doubt is, in spite of the missing break statements in the second case,
 how will it enter case 4, as it should check if x=4 before doing that,
 which is not true.

  --
 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] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread saurabh singh
^ Does it make any difference?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Jun 26, 2012 at 5:32 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 whether it is in character array or integer array??


 On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel ashg...@gmail.com wrote:


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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] Programming Question

2012-06-22 Thread saurabh singh
+1 to Trie

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Jun 22, 2012 at 3:50 PM, Karthikeyan V.B kartmu...@gmail.comwrote:

 Tries

 --
 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] Reverse Queue

2012-06-20 Thread saurabh singh
count the size of queue : O(n)
loop for n and do remove and add in queue : O(n)

Total : O(n)

On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 How to reverse a Queue .

 Constraints: Time complexity O(n). space complexity: O(1)

  --
 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/-/kepls-8qRwgJ.
 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.




-- 
Thanks  Regards,
Saurabh

-- 
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] Reverse Queue

2012-06-20 Thread saurabh singh
I meant do it for n-1 times (my focus was on time complexity).Try with more
examples and you will know :)

On Wed, Jun 20, 2012 at 6:50 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 For ex: let only two element are in queue: 1 2 (1 at front and rear is at
 2).
 looping two times:

 first time: delete from front and adding to rear: queue will be: 2 1(front
 at 2 , rear at 1)

 second iteration: deleting 2 and adding to queue :result will be: 1 2
 (front 1, rear 2)


 On Wed, Jun 20, 2012 at 6:46 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @Saurabh: queue will be remain unchanged according to your algorithm.
 Because if you will delete an element from front and add at rear no change
 will be there. After n iteration front will be pointing to same element and
 rear will also point to same element.

 Correct me if i am wrong. :)


 On Wed, Jun 20, 2012 at 6:39 PM, saurabh singh saurabh.n...@gmail.comwrote:

 count the size of queue : O(n)
 loop for n and do remove and add in queue : O(n)

 Total : O(n)


 On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar 
 algorithm.i...@gmail.comwrote:

 How to reverse a Queue .

 Constraints: Time complexity O(n). space complexity: O(1)

  --
 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/-/kepls-8qRwgJ.
 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.




 --
 Thanks  Regards,
 Saurabh

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




-- 
Thanks  Regards,
Saurabh

-- 
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] Reverse Queue

2012-06-20 Thread saurabh singh
Why will my proposed solution not work for you ???

On Wed, Jun 20, 2012 at 8:19 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @Kirubakaran : still space complexity is O(n) due to stack.Can it be
 solved in space complexity O(1).


 On Wed, Jun 20, 2012 at 8:00 PM, Kirubakaran D kirubakara...@gmail.comwrote:

 You could use recursion.

 def reverse_Q q
 if !q.isEmpty?
   el = q.dequeue
   nQ = reverse_Q(q)
   nQ.enqueue el
   return nQ
 end
 return q
 end



 On Wednesday, June 20, 2012 6:57:23 PM UTC+5:30, Navin Kumar wrote:

 Use only standard operation of Queue like: EnQueue, DeQueue,
 IsEmptyQueue etc

 On Wed, Jun 20, 2012 at 6:50 PM, amrit harry dabbcomput...@gmail.comwrote:

 can we create other methods or we have to use only enqueue and
 dequeue...? if yes then simply
 for(i=0;i=n/2;i++)
 swap(i,n-i);



 On Wed, Jun 20, 2012 at 6:46 PM, Navin Kumar 
 algorithm.i...@gmail.comwrote:

 @Saurabh: queue will be remain unchanged according to your algorithm.
 Because if you will delete an element from front and add at rear no change
 will be there. After n iteration front will be pointing to same element 
 and
 rear will also point to same element.

 Correct me if i am wrong. :)


 On Wed, Jun 20, 2012 at 6:39 PM, saurabh singh saurabh.n...@gmail.com
  wrote:

 count the size of queue : O(n)
 loop for n and do remove and add in queue : O(n)

 Total : O(n)


 On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar 
 algorithm.i...@gmail.com wrote:

 How to reverse a Queue .

 Constraints: Time complexity O(n). space complexity: O(1)

  --
 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/-/kepls-8qRwgJhttps://groups.google.com/d/msg/algogeeks/-/kepls-8qRwgJ
 .
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+unsubscribe@
 **googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .




 --
 Thanks  Regards,
 Saurabh

 --
 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+unsubscribe@*
 *googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en
 .




 --
 Thanks  Regards
 Amritpal singh

  --
 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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


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

 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.




-- 
Thanks  Regards,
Saurabh

-- 
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] Reverse Queue

2012-06-20 Thread saurabh singh
How ??
I am asking to manipulate the same queue.
Dequeue n-1 elements and enqueue them in order to you take out to the same
queue..Where is extra space involved ?

On Wed, Jun 20, 2012 at 8:36 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @saurabh : i want solution with space complexity of O(1) . your solution
 is right but it takes O(n) space.


 On Wed, Jun 20, 2012 at 8:28 PM, saurabh singh saurabh.n...@gmail.comwrote:

 Why will my proposed solution not work for you ???


 On Wed, Jun 20, 2012 at 8:19 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @Kirubakaran : still space complexity is O(n) due to stack.Can it be
 solved in space complexity O(1).


 On Wed, Jun 20, 2012 at 8:00 PM, Kirubakaran D 
 kirubakara...@gmail.comwrote:

 You could use recursion.

 def reverse_Q q
 if !q.isEmpty?
   el = q.dequeue
   nQ = reverse_Q(q)
   nQ.enqueue el
   return nQ
 end
 return q
 end



 On Wednesday, June 20, 2012 6:57:23 PM UTC+5:30, Navin Kumar wrote:

 Use only standard operation of Queue like: EnQueue, DeQueue,
 IsEmptyQueue etc

 On Wed, Jun 20, 2012 at 6:50 PM, amrit harry 
 dabbcomput...@gmail.comwrote:

 can we create other methods or we have to use only enqueue and
 dequeue...? if yes then simply
 for(i=0;i=n/2;i++)
 swap(i,n-i);



 On Wed, Jun 20, 2012 at 6:46 PM, Navin Kumar 
 algorithm.i...@gmail.com wrote:

 @Saurabh: queue will be remain unchanged according to your
 algorithm. Because if you will delete an element from front and add at 
 rear
 no change will be there. After n iteration front will be pointing to 
 same
 element and rear will also point to same element.

 Correct me if i am wrong. :)


 On Wed, Jun 20, 2012 at 6:39 PM, saurabh singh 
 saurabh.n...@gmail.com wrote:

 count the size of queue : O(n)
 loop for n and do remove and add in queue : O(n)

 Total : O(n)


 On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar 
 algorithm.i...@gmail.com wrote:

 How to reverse a Queue .

 Constraints: Time complexity O(n). space complexity: O(1)

  --
 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/-/kepls-8qRwgJhttps://groups.google.com/d/msg/algogeeks/-/kepls-8qRwgJ
 .
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .




 --
 Thanks  Regards,
 Saurabh

 --
 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+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://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+unsubscribe@
 **googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .




 --
 Thanks  Regards
 Amritpal singh

  --
 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+unsubscribe@*
 *googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .


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

 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.




 --
 Thanks  Regards,
 Saurabh

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

Re: [algogeeks] Reverse Queue

2012-06-20 Thread saurabh singh
My bad...Sorry :(..Yes it certainly was not right

On Wed, Jun 20, 2012 at 8:56 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @Saurabh:i was wrong in deciding space complexity. Yes, your algo will
 take O(1) time but you have to enqueue elements in reverse order.Not in the
 order you fetched. Think about it :). Then you have to take stack or some
 other data structure.


 On Wed, Jun 20, 2012 at 8:40 PM, saurabh singh saurabh.n...@gmail.comwrote:

 How ??
 I am asking to manipulate the same queue.
 Dequeue n-1 elements and enqueue them in order to you take out to the
 same queue..Where is extra space involved ?


 On Wed, Jun 20, 2012 at 8:36 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @saurabh : i want solution with space complexity of O(1) . your solution
 is right but it takes O(n) space.


 On Wed, Jun 20, 2012 at 8:28 PM, saurabh singh 
 saurabh.n...@gmail.comwrote:

 Why will my proposed solution not work for you ???


 On Wed, Jun 20, 2012 at 8:19 PM, Navin Kumar 
 algorithm.i...@gmail.comwrote:

 @Kirubakaran : still space complexity is O(n) due to stack.Can it be
 solved in space complexity O(1).


 On Wed, Jun 20, 2012 at 8:00 PM, Kirubakaran D 
 kirubakara...@gmail.com wrote:

 You could use recursion.

 def reverse_Q q
 if !q.isEmpty?
   el = q.dequeue
   nQ = reverse_Q(q)
   nQ.enqueue el
   return nQ
 end
 return q
 end



 On Wednesday, June 20, 2012 6:57:23 PM UTC+5:30, Navin Kumar wrote:

 Use only standard operation of Queue like: EnQueue, DeQueue,
 IsEmptyQueue etc

 On Wed, Jun 20, 2012 at 6:50 PM, amrit harry 
 dabbcomput...@gmail.com wrote:

 can we create other methods or we have to use only enqueue and
 dequeue...? if yes then simply
 for(i=0;i=n/2;i++)
 swap(i,n-i);



 On Wed, Jun 20, 2012 at 6:46 PM, Navin Kumar 
 algorithm.i...@gmail.com wrote:

 @Saurabh: queue will be remain unchanged according to your
 algorithm. Because if you will delete an element from front and add 
 at rear
 no change will be there. After n iteration front will be pointing to 
 same
 element and rear will also point to same element.

 Correct me if i am wrong. :)


 On Wed, Jun 20, 2012 at 6:39 PM, saurabh singh 
 saurabh.n...@gmail.com wrote:

 count the size of queue : O(n)
 loop for n and do remove and add in queue : O(n)

 Total : O(n)


 On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar 
 algorithm.i...@gmail.com wrote:

 How to reverse a Queue .

 Constraints: Time complexity O(n). space complexity: O(1)

  --
 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/-/kepls-8qRwgJhttps://groups.google.com/d/msg/algogeeks/-/kepls-8qRwgJ
 .
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/*
 *group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .




 --
 Thanks  Regards,
 Saurabh

 --
 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+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://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+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .




 --
 Thanks  Regards
 Amritpal singh

  --
 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+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .


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

 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

Re: [algogeeks] Microsoft Interview Question

2012-06-14 Thread saurabh singh
Order may not be maintained necessarily by this solution
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jun 14, 2012 at 1:47 PM, Manikanta Babu
manikantabab...@gmail.comwrote:

 Check this out, it works in O(n);

 int i = 0;
 int j = n-1;

 while((in  j= 0)(ij))
 {
 if(a[i]0  a[j]0)
 {
 swap(a[i],a[j]);
 i++; j--;
 }
 else
 {
 if(a[i]0)
 i++;
 if(a[j]0)
 j--;
 }

 }

 Thanks,
 Mani

 On Thu, Jun 14, 2012 at 1:05 PM, Mad Coder imamadco...@gmail.com wrote:


 As nothing is written about space complexity, I am assuming that we can
 take extra space.

 Take a temporary array of length n.

 1. Maintain a counter for the length of temporary array filled till now.

 2. Traverse the given array. If value contained is negative insert it in
 new array and update counter. After complete traversal all negative values
 will be in the temporary array.

 3. Traverse again the given array. Repeat step 2 but this time for
 positive numbers.

 Finally temporary array contains the required answer. If required copy it
 into original array.

 As this approach takes max. 3 traversals so its complexity is O(n).

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




 --
 Thanks  Regards,
 Mani
 http://www.sanidapa.com - The music Search engine

  --
 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: Book Feedback needed for book from Narasimha Karumanchi

2012-06-14 Thread saurabh singh
Kindly find some other group for requesting e-books-
www.squiffer.com This is a good reference for ebooks.Any more requests for
uploading ebooks may result in a ban from the group.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Jun 8, 2012 at 7:05 PM, Decipher ankurseth...@gmail.com wrote:

 Does anybody has its ebook ? Please upload it

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

 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: spoj problem

2012-06-13 Thread saurabh singh
No this is fair enough.It directly involves algorithm.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jun 14, 2012 at 4:28 AM, shiv narayan narayan.shiv...@gmail.comwrote:

 will be better if you post on spoj forums.!!


 On Wednesday, 13 June 2012 01:40:36 UTC+5:30, gaurav yadav wrote:

 plz nyone explain how to approach this problem..
 http://www.spoj.pl/problems/**XORROUND/http://www.spoj.pl/problems/XORROUND/

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

 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] Microsoft Interview Question

2012-06-13 Thread saurabh singh
Think of the +ve numbers as 0 negative numbers as 1.Now the problem reduces
to http://stackoverflow.com/questions/682171/arrange-0s-1s-in-a-array
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jun 14, 2012 at 3:00 AM, Piyush Kapoor pkjee2...@gmail.com wrote:

  your solutions , order won't be maintained in your solutions.


-- 
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] Adobe interiew question

2012-06-12 Thread saurabh singh
tHE first thing that comes in my mind Signals
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Jun 12, 2012 at 10:26 PM, Shashank Narayan 
shashank7andr...@gmail.com wrote:

 yes u can review that link :)

 On Tue, Jun 12, 2012 at 9:47 PM, Anika Jain anika.jai...@gmail.comwrote:

 how can we implement exception handling in c?

 --
 Regards
 Anika Jain

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




 --
 *Thanks
 Shashank Mani Narayan
 Computer Science  Engineering
 Birla Institute of Technology,Mesra
 ** Founder Cracking The Code Lab  http://shashank7s.blogspot.com/;
 FB Page http://www.facebook.com/pages/Cracking-The-Code/148241881919895
 Google+ http://gplus.to/wgpshashank
  Twitter 
 https://twitter.com/wgpshashankhttps://twitter.com/#%21/wgpshashank
 
 Puzzled Guy @ http://ashutosh7s.blogspot.com**
 **FB Page http://www.facebook.com/Puzzles.For.Puzzled.Minds*
 * Key Person Algogeek https://groups.google.com/forum/#!forum 
 /algogeekshttps://groups.google.com/forum/#%21forum/algogeeks
 
 **Cell +91-9740852296
 *


 *
 **
 *

  --
 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: Power(n^n)

2012-06-11 Thread saurabh singh
@Guneesh Actually he says But 0=N , K=1000 so N^N could be have 1000
digits. I think this assertion is wrong..
@dave sir.. The second part of question still remains unanswered.Is there
any mathematical property...
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Mon, Jun 11, 2012 at 1:56 PM, Guneesh Paul Singh gunees...@gmail.comwrote:

 @abhisheikh read the problem statement again...it says 1000 digits not
 1000 value..


  --
 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] first Repeating character in a string

2012-06-08 Thread saurabh singh
The key doesn't lies in the way it will be solved.It is how efficiently you
implement the hash table.do  we really need an integer array ( 4*256 bytes)
just to record the first occurrence of a character?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Jun 8, 2012 at 2:36 PM, Nishant Pandey nishant.bits.me...@gmail.com
 wrote:

 you may use look up table for each character like this :

 int table[255]={0};

 for(int i=0;str[i];i++)
 {
 if( table[str[i]] )
 return true;
else
 {
 table[str[i]]=1;
 }

 }
 return false;


 On Fri, Jun 8, 2012 at 2:26 PM, Anika Jain anika.jai...@gmail.com wrote:

 you will have to note time for of occurence of a character for all chars


 On Fri, Jun 8, 2012 at 2:15 PM, himanshu kansal 
 himanshukansal...@gmail.com wrote:

 how can we find 1st repeating character in string???
 e.g. if the string is abba it should return 'b' and not 'a'.

 note: hashing will give the answer as 'a'

 --
 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
 Anika Jain

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




 --
 Cheers,

 Nishant Pandey |Specialist Tools Development  |  
 npan...@google.comgvib...@google.com |
 +91-9911258345


  --
 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: Tree/Graph implementation

2012-05-29 Thread saurabh singh
^ A list representation 
consider a graph with 1 million nodes..and at a time only 2  nodes will be
connected...Compare the difference in the two representations...
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, May 29, 2012 at 10:00 PM, Ashish Goel ashg...@gmail.com wrote:

 Gene: why do you say that adjacency list is not a good solution for sparse
 matrix? what other alternates are you looking at?

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Tue, May 29, 2012 at 9:09 PM, Gene gene.ress...@gmail.com wrote:

 I'm interested to see problems where tree implementation causes a
 performance problem.  Example?

 Choice of graph data structures is very problem-dependent. An
 adjacency matrix will probably be fastest and simplest for dense
 graphs.  For sparse ones there are many, many answers.

 An efficient way to do n-ary trees (which are usually sparse graphs)
 in C:

 typedef struct node_s {
  // Use a fixed size array of NODE* if you know
  // the maximum number of children in advance.
  // Here we assume this isn't true.
  struct node_s **children;
  int n_children;
  ...
 } NODE;

 NODE *make_node(int max_children)
 {
  // Allocate nodes in a single array if you know the max
  // number in advance.  Here we assume this isn't true.
  NODE *node = safe_malloc(sizeof *node);
  node-children = safe_malloc(max_children * sizeof *node-children);
  node-n_children = 0;
  return node;
 }

 void add_child(NODE *parent, NODE *child)
 {
  parent-children[parent-n_children++] = child;
 }

 void walk

 On May 29, 6:17 am, prakash y yprakash@gmail.com wrote:
  How to implement complex data structures like trees (with unknown no.of
  subtrees) and graphs efficiently in C/Java?
  I have implemented binary trees in Java as it always contains two nodes.
  But I don't know about graphs.
  I am not able to solve these problems in coding contests because of
 this.
  Can anyone please suggest me?
 
  Thanks in advance.
  ~Prakash.

 --
 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] Partition the array with equal average

2012-05-18 Thread saurabh singh
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, May 17, 2012 at 11:40 PM, Prem Krishna Chettri
hprem...@gmail.comwrote:

 I guess this is Subset minimization problem's Modification..


 Algo..

 1 Get all the Subset of the particular array. Best Algo O(n2).

''
How?


 2 Now try to find the subsets having similar average. Again best algo
 known is O(n2).


 Anyone have better options??

 BR,
 Prem


 On Fri, May 18, 2012 at 12:05 PM, payal gupta gpt.pa...@gmail.com wrote:

  How do you partition an array into 2 parts such that the two parts have
 equal average?...each partition may contain elements that are
 non-contiguous in the array...

  --
 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/-/fSAXqe-gkJcJ.
 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: finding anagrams in a list of words

2012-05-14 Thread saurabh singh
u mean ad == bc ?

On Mon, May 14, 2012 at 10:41 PM, payal gupta gpt.pa...@gmail.com wrote:

 @atul
 instead of sorting the string individually which would require tc-
 O(nlogn) shouldnot it be a better idea to use the sum of the ascii values
 of the individual alphabets as the key which would require tc-O(n) ???



 On Sun, May 13, 2012 at 7:07 PM, GAURAV CHAWLA 
 togauravcha...@gmail.comwrote:

 @deepikaanand:


 1 is not a prime no. and also ignore 2 as chosen prime no,.

 On Sun, May 13, 2012 at 6:31 PM, deepikaanand swinyanand...@gmail.comwrote:


 @gaurav
 the approach suggested as : to have an array of 25 prime nos..How is
 it supposed to work ;
 cz(this is wat i have understood) if a :0 ,b:1,c:3,d:5,e:7
 then be = b + e = 1+7 =8
 and  dc = d + c =5 +3 = 8..

 --
 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,
 GAURAV CHAWLA
 +919992635751
 +919654127192




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




-- 
Thanks  Regards,
Saurabh

-- 
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: Sorting in O(n)

2012-05-08 Thread saurabh singh
what he wanted to say was that first digit would be m/n and second digit m%n
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, May 8, 2012 at 10:31 AM, atul anand atul.87fri...@gmail.com wrote:

 @arpit : your formula for converting base 10 to base n is bit wrong ,
 right formula should be :-


 let given base 10 no is m and we need to convert it in base n.
 then base n converted no is ( (m/n) * 10) + (m%n) ie 34 base 10 in base 6
 is ((34/6)*10) + (34%6) ie 54


 On Sun, May 6, 2012 at 10:20 PM, Arpit Gupta 
 arpitgupta.211...@gmail.comwrote:

 O(1) base conversion can here be done as follows:-(works only when
 numbers are in range 0 to n^2-1)
 *From base 10 to base n
 *let given base 10 no is m and we need to convert it in base n.
 then base n converted no is (m/n)(m%n) ie 34 base 10 in base 6 is
 (34/6)(34%6) ie 54

 Now i think you can yourself write base n to base 10 conversion.


 On Sun, May 6, 2012 at 11:13 AM, saurabh singh saurab...@gmail.comwrote:

 ^ And this completes the solution

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sun, May 6, 2012 at 11:12 AM, Gene gene.ress...@gmail.com wrote:

 Ah, but you can pick the radix to be n.  Then at most 3 passes will
 always sort the array. O(3n) = O(n), so you are done.

 This topic has come up before.  There is code at
 http://groups.google.com/group/algogeeks/msg/90ce2df194aba2d2 .

 It is true this code assumes math including mod takes constant time,
 but that's normal for RAM computation models used for most algorithms.

 Gene

 On May 5, 4:32 am, saurabh singh saurab...@gmail.com wrote:
  After giving some thought,I think even radix sort may not be
 sufficient.
  Complexity of radix sort is O(k*n) where k is the number of buckets
  required to sort the given range.
  The number of buckets is proportional to the number of bits required
 to
  represent the *maximum number in the given range.*For our case the
 maximum
  number is O(n^2).Hence *the number of buckets required would be
  proportional to log(n^2) in the worst case.*
  Hence the worst case complexity for the given constraints using radix
 sort
  would be *O(n*(log n^2)) = O(n*logn).*
  This is no better than comparision sort.A slight optimization that we
 can
  make is to use a higher base which would reduce the number of buckets
  required but would add the cost of converting each number into  the
 higher
  base.
  Somehow I am getting convinced worst case O(n) algorithm may not be
  possible.Working on the mathematical proof.
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com
 wrote:
   @cegprakash They are n numbers lying in the range 1 to n^2.Not
 necessarily
   sorted.
   eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the
 problem)
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com
 wrote:
 
   The range 1 to n^2 is already sorted
 
   On Sat, May 5, 2012 at 12:17 AM, Algobiz 
 deepak.arulkan...@gmail.com
   wrote:
How to sort n numbers in the range of 1 to n^2 in O(n).. Any
 ideas?
 
--
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/-/PGgMdaIbGIsJ.
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.




 --
 Arpit Gupta
 B.Tech Third Year
 Computer Science And Engineering
 M.N.N.I.T Allahabad
 arpitgupta.211...@gmail.com

  --
 You received this message

Re: [algogeeks] Re: Sorting in O(n)

2012-05-08 Thread saurabh singh
Read the problem for constraints
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, May 8, 2012 at 11:12 AM, Mahesh Thakur tmahesh...@gmail.com wrote:

 I think if range is till n2, max passes for radix sort will be 3.
 by subtracting 1 to all the numbers we get the max range to n2-1 and radix
 sort can be done in 2 passes.
 but what will happen when if we have a '0' in array and then we subtract 1
 to it?


 On Tue, May 8, 2012 at 9:48 AM, atul anand atul.87fri...@gmail.comwrote:

 @arpit : why algo subtracts 1 from each number of the input?

 On Sun, May 6, 2012 at 12:02 AM, Arpit Gupta arpitgupta.211...@gmail.com
  wrote:

 1) Substract 1 from each no.
 2) Now after substracting 1 from each no, convert it to base n.
 for example for n=6,the number 36 will be converted to 55.   (36-1=35
 and 35 when converted to base 6 is 55)
 3) Thus all the nos in the range 1 to 6^2 can be mapped to numbers
 between 00 to 55.
 4) Now apply radix sort(for two digits) for the mapped values.
 5)After sorting the mapped values convert base n values to decimal and
 add 1.

 This is o(n) algo.
 PS: I am not the designer of this algo. One of my seniors told me.


 On Sat, May 5, 2012 at 2:42 PM, saurabh singh saurab...@gmail.comwrote:

 I think I couldn't make myself clear...
 This line in your algorithm *After this just iterate through the aux
 array printing the index aux[i] times.*
 this makes your algorithm O(n^2) since the size of aux is n^2 and in
 the worst case the complete traversal of aux may be required.

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 2:37 PM, Jeevitesh jeeviteshshekha...@gmail.com
  wrote:

 Hi Shiva.

 You are right we will be wasting a lot of memory.
 But still it depends like if we have lot of numbers in the range of 1,
 n^2 present in the input array then this trade off is not bad.
 The issue here is we cannot otherwise sort it in O(n) time unless and
 until we have extra space.

 So we will have to live with it in this case as i do not think it
 would be possible in O(n) time otherwise.


 On Sat, May 5, 2012 at 2:33 PM, shiv narayan 
 narayan.shiv...@gmail.com wrote:

 @jeevitesh yeah that may be right but it requires extra space as lot
 of space will be wasted...

 On May 5, 1:44 pm, Jeevitesh jeeviteshshekha...@gmail.com wrote:
  Hi all,
 
  I am new to this group.
 
  My last post was deleted i do not know the reason behind it.
 
  I will explain my logic here:-
 
  as the range is 1 to n^2 we have a input array like input[n^2].
  We can take a auxillary array of size n^2 like aux[n^2].
  Scan the input array.
  For each input input[i] increment by one corresponding
 aux[input[i]].
  After this just iterate through the aux array printing the index
 aux[i]
  times.
 
  This way we can sort it in O(n) time.
 
 
 
 
 
 
 
 
 
  On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com
 wrote:
   After giving some thought,I think even radix sort may not be
 sufficient.
   Complexity of radix sort is O(k*n) where k is the number of
 buckets
   required to sort the given range.
   The number of buckets is proportional to the number of bits
 required to
   represent the *maximum number in the given range.*For our case the
   maximum number is O(n^2).Hence *the number of buckets required
 would be
   proportional to log(n^2) in the worst case.*
   Hence the worst case complexity for the given constraints using
 radix sort
   would be *O(n*(log n^2)) = O(n*logn).*
   This is no better than comparision sort.A slight optimization
 that we can
   make is to use a higher base which would reduce the number of
 buckets
   required but would add the cost of converting each number into
  the higher
   base.
   Somehow I am getting convinced worst case O(n) algorithm may not
 be
   possible.Working on the mathematical proof.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 8:37 AM, saurabh singh 
 saurab...@gmail.com wrote:
 
   @cegprakash They are n numbers lying in the range 1 to n^2.Not
   necessarily sorted.
   eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the
 problem)
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com
 wrote:
 
   The range 1 to n^2 is already sorted
 
   On Sat, May 5, 2012 at 12:17 AM, Algobiz 
 deepak.arulkan...@gmail.com
   wrote:
How to sort n numbers in the range of 1 to n^2 in O(n).. Any
 ideas?
 
--
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/-/PGgMdaIbGIsJ.
To post to this group, send email to
 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks

Re: [algogeeks] Re: Sorting in O(n)

2012-05-06 Thread saurabh singh
Yes thanx for that...Gene had already mentioned that in somewhat different
way.And now I feel like a floppy disk for not being able to think the
obvious.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, May 6, 2012 at 10:20 PM, Arpit Gupta arpitgupta.211...@gmail.comwrote:

 O(1) base conversion can here be done as follows:-(works only when numbers
 are in range 0 to n^2-1)
 *From base 10 to base n
 *let given base 10 no is m and we need to convert it in base n.
 then base n converted no is (m/n)(m%n) ie 34 base 10 in base 6 is
 (34/6)(34%6) ie 54

 Now i think you can yourself write base n to base 10 conversion.


 On Sun, May 6, 2012 at 11:13 AM, saurabh singh saurab...@gmail.comwrote:

 ^ And this completes the solution

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sun, May 6, 2012 at 11:12 AM, Gene gene.ress...@gmail.com wrote:

 Ah, but you can pick the radix to be n.  Then at most 3 passes will
 always sort the array. O(3n) = O(n), so you are done.

 This topic has come up before.  There is code at
 http://groups.google.com/group/algogeeks/msg/90ce2df194aba2d2 .

 It is true this code assumes math including mod takes constant time,
 but that's normal for RAM computation models used for most algorithms.

 Gene

 On May 5, 4:32 am, saurabh singh saurab...@gmail.com wrote:
  After giving some thought,I think even radix sort may not be
 sufficient.
  Complexity of radix sort is O(k*n) where k is the number of buckets
  required to sort the given range.
  The number of buckets is proportional to the number of bits required to
  represent the *maximum number in the given range.*For our case the
 maximum
  number is O(n^2).Hence *the number of buckets required would be
  proportional to log(n^2) in the worst case.*
  Hence the worst case complexity for the given constraints using radix
 sort
  would be *O(n*(log n^2)) = O(n*logn).*
  This is no better than comparision sort.A slight optimization that we
 can
  make is to use a higher base which would reduce the number of buckets
  required but would add the cost of converting each number into  the
 higher
  base.
  Somehow I am getting convinced worst case O(n) algorithm may not be
  possible.Working on the mathematical proof.
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com
 wrote:
   @cegprakash They are n numbers lying in the range 1 to n^2.Not
 necessarily
   sorted.
   eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the
 problem)
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com
 wrote:
 
   The range 1 to n^2 is already sorted
 
   On Sat, May 5, 2012 at 12:17 AM, Algobiz 
 deepak.arulkan...@gmail.com
   wrote:
How to sort n numbers in the range of 1 to n^2 in O(n).. Any
 ideas?
 
--
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/-/PGgMdaIbGIsJ.
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.




 --
 Arpit Gupta
 B.Tech Third Year
 Computer Science And Engineering
 M.N.N.I.T Allahabad
 arpitgupta.211...@gmail.com

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http

Re: [algogeeks] Sorting in O(n)

2012-05-05 Thread saurabh singh
After giving some thought,I think even radix sort may not be sufficient.
Complexity of radix sort is O(k*n) where k is the number of buckets
required to sort the given range.
The number of buckets is proportional to the number of bits required to
represent the *maximum number in the given range.*For our case the maximum
number is O(n^2).Hence *the number of buckets required would be
proportional to log(n^2) in the worst case.*
Hence the worst case complexity for the given constraints using radix sort
would be *O(n*(log n^2)) = O(n*logn).*
This is no better than comparision sort.A slight optimization that we can
make is to use a higher base which would reduce the number of buckets
required but would add the cost of converting each number into  the higher
base.
Somehow I am getting convinced worst case O(n) algorithm may not be
possible.Working on the mathematical proof.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com wrote:

 @cegprakash They are n numbers lying in the range 1 to n^2.Not necessarily
 sorted.
 eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  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/-/PGgMdaIbGIsJ.
  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] Sorting in O(n)

2012-05-05 Thread saurabh singh
Consider the case
n=6
array elements :-
{36 36 36 36 36 36}
How many iterations your code makes?
Consider another case
n=100
array={1e12,1e12 ..repeated 10^6 times}
How many iterations your code make?
Are the iterations still proportional to n that is the number of elements
in the array?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 2:14 PM, Jeevitesh jeeviteshshekha...@gmail.comwrote:

 Hi all,

 I am new to this group.

 My last post was deleted i do not know the reason behind it.

 I will explain my logic here:-

 as the range is 1 to n^2 we have a input array like input[n^2].
 We can take a auxillary array of size n^2 like aux[n^2].
 Scan the input array.
 For each input input[i] increment by one corresponding aux[input[i]].
 After this just iterate through the aux array printing the index aux[i]
 times.

 This way we can sort it in O(n) time.


 On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com wrote:

 After giving some thought,I think even radix sort may not be sufficient.
 Complexity of radix sort is O(k*n) where k is the number of buckets
 required to sort the given range.
 The number of buckets is proportional to the number of bits required to
 represent the *maximum number in the given range.*For our case the
 maximum number is O(n^2).Hence *the number of buckets required would be
 proportional to log(n^2) in the worst case.*
 Hence the worst case complexity for the given constraints using radix
 sort would be *O(n*(log n^2)) = O(n*logn).*
 This is no better than comparision sort.A slight optimization that we can
 make is to use a higher base which would reduce the number of buckets
 required but would add the cost of converting each number into  the higher
 base.
 Somehow I am getting convinced worst case O(n) algorithm may not be
 possible.Working on the mathematical proof.

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.comwrote:

 @cegprakash They are n numbers lying in the range 1 to n^2.Not
 necessarily sorted.
 eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  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/-/PGgMdaIbGIsJ.
  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.




 --
 *Thanks,
 Jeevitesh Shekhar Singh.*


  --
 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: Sorting in O(n)

2012-05-05 Thread saurabh singh
I think I couldn't make myself clear...
This line in your algorithm *After this just iterate through the aux array
printing the index aux[i] times.*
this makes your algorithm O(n^2) since the size of aux is n^2 and in the
worst case the complete traversal of aux may be required.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 2:37 PM, Jeevitesh jeeviteshshekha...@gmail.comwrote:

 Hi Shiva.

 You are right we will be wasting a lot of memory.
 But still it depends like if we have lot of numbers in the range of 1, n^2
 present in the input array then this trade off is not bad.
 The issue here is we cannot otherwise sort it in O(n) time unless and
 until we have extra space.

 So we will have to live with it in this case as i do not think it would be
 possible in O(n) time otherwise.


 On Sat, May 5, 2012 at 2:33 PM, shiv narayan narayan.shiv...@gmail.comwrote:

 @jeevitesh yeah that may be right but it requires extra space as lot
 of space will be wasted...

 On May 5, 1:44 pm, Jeevitesh jeeviteshshekha...@gmail.com wrote:
  Hi all,
 
  I am new to this group.
 
  My last post was deleted i do not know the reason behind it.
 
  I will explain my logic here:-
 
  as the range is 1 to n^2 we have a input array like input[n^2].
  We can take a auxillary array of size n^2 like aux[n^2].
  Scan the input array.
  For each input input[i] increment by one corresponding aux[input[i]].
  After this just iterate through the aux array printing the index aux[i]
  times.
 
  This way we can sort it in O(n) time.
 
 
 
 
 
 
 
 
 
  On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com
 wrote:
   After giving some thought,I think even radix sort may not be
 sufficient.
   Complexity of radix sort is O(k*n) where k is the number of buckets
   required to sort the given range.
   The number of buckets is proportional to the number of bits required
 to
   represent the *maximum number in the given range.*For our case the
   maximum number is O(n^2).Hence *the number of buckets required would
 be
   proportional to log(n^2) in the worst case.*
   Hence the worst case complexity for the given constraints using radix
 sort
   would be *O(n*(log n^2)) = O(n*logn).*
   This is no better than comparision sort.A slight optimization that we
 can
   make is to use a higher base which would reduce the number of buckets
   required but would add the cost of converting each number into  the
 higher
   base.
   Somehow I am getting convinced worst case O(n) algorithm may not be
   possible.Working on the mathematical proof.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com
 wrote:
 
   @cegprakash They are n numbers lying in the range 1 to n^2.Not
   necessarily sorted.
   eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the
 problem)
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com
 wrote:
 
   The range 1 to n^2 is already sorted
 
   On Sat, May 5, 2012 at 12:17 AM, Algobiz 
 deepak.arulkan...@gmail.com
   wrote:
How to sort n numbers in the range of 1 to n^2 in O(n).. Any
 ideas?
 
--
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/-/PGgMdaIbGIsJ.
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.
 
  --
  *Thanks,
  Jeevitesh Shekhar Singh.*

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

Re: [algogeeks] Re: Sorting in O(n)

2012-05-05 Thread saurabh singh
^ This is what I was talking about in my earlier post.But the problem is
how\ to convert the base of each number in O(1) time ( and then reconvert
to base 10 in  O(n)) .I may be missing some trick here.Still working on it.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, May 6, 2012 at 12:02 AM, Arpit Gupta arpitgupta.211...@gmail.comwrote:

 1) Substract 1 from each no.
 2) Now after substracting 1 from each no, convert it to base n.
 for example for n=6,the number 36 will be converted to 55.   (36-1=35 and
 35 when converted to base 6 is 55)
 3) Thus all the nos in the range 1 to 6^2 can be mapped to numbers between
 00 to 55.
 4) Now apply radix sort(for two digits) for the mapped values.
 5)After sorting the mapped values convert base n values to decimal and add
 1.

 This is o(n) algo.
 PS: I am not the designer of this algo. One of my seniors told me.


 On Sat, May 5, 2012 at 2:42 PM, saurabh singh saurab...@gmail.com wrote:

 I think I couldn't make myself clear...
 This line in your algorithm *After this just iterate through the aux
 array printing the index aux[i] times.*
 this makes your algorithm O(n^2) since the size of aux is n^2 and in the
 worst case the complete traversal of aux may be required.

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 2:37 PM, Jeevitesh 
 jeeviteshshekha...@gmail.comwrote:

 Hi Shiva.

 You are right we will be wasting a lot of memory.
 But still it depends like if we have lot of numbers in the range of 1,
 n^2 present in the input array then this trade off is not bad.
 The issue here is we cannot otherwise sort it in O(n) time unless and
 until we have extra space.

 So we will have to live with it in this case as i do not think it would
 be possible in O(n) time otherwise.


 On Sat, May 5, 2012 at 2:33 PM, shiv narayan 
 narayan.shiv...@gmail.comwrote:

 @jeevitesh yeah that may be right but it requires extra space as lot
 of space will be wasted...

 On May 5, 1:44 pm, Jeevitesh jeeviteshshekha...@gmail.com wrote:
  Hi all,
 
  I am new to this group.
 
  My last post was deleted i do not know the reason behind it.
 
  I will explain my logic here:-
 
  as the range is 1 to n^2 we have a input array like input[n^2].
  We can take a auxillary array of size n^2 like aux[n^2].
  Scan the input array.
  For each input input[i] increment by one corresponding aux[input[i]].
  After this just iterate through the aux array printing the index
 aux[i]
  times.
 
  This way we can sort it in O(n) time.
 
 
 
 
 
 
 
 
 
  On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com
 wrote:
   After giving some thought,I think even radix sort may not be
 sufficient.
   Complexity of radix sort is O(k*n) where k is the number of buckets
   required to sort the given range.
   The number of buckets is proportional to the number of bits
 required to
   represent the *maximum number in the given range.*For our case the
   maximum number is O(n^2).Hence *the number of buckets required
 would be
   proportional to log(n^2) in the worst case.*
   Hence the worst case complexity for the given constraints using
 radix sort
   would be *O(n*(log n^2)) = O(n*logn).*
   This is no better than comparision sort.A slight optimization that
 we can
   make is to use a higher base which would reduce the number of
 buckets
   required but would add the cost of converting each number into  the
 higher
   base.
   Somehow I am getting convinced worst case O(n) algorithm may not be
   possible.Working on the mathematical proof.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com
 wrote:
 
   @cegprakash They are n numbers lying in the range 1 to n^2.Not
   necessarily sorted.
   eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the
 problem)
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com
 wrote:
 
   The range 1 to n^2 is already sorted
 
   On Sat, May 5, 2012 at 12:17 AM, Algobiz 
 deepak.arulkan...@gmail.com
   wrote:
How to sort n numbers in the range of 1 to n^2 in O(n).. Any
 ideas?
 
--
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/-/PGgMdaIbGIsJ.
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

Re: [algogeeks] Re: Sorting in O(n)

2012-05-05 Thread saurabh singh
^ And this completes the solution
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, May 6, 2012 at 11:12 AM, Gene gene.ress...@gmail.com wrote:

 Ah, but you can pick the radix to be n.  Then at most 3 passes will
 always sort the array. O(3n) = O(n), so you are done.

 This topic has come up before.  There is code at
 http://groups.google.com/group/algogeeks/msg/90ce2df194aba2d2 .

 It is true this code assumes math including mod takes constant time,
 but that's normal for RAM computation models used for most algorithms.

 Gene

 On May 5, 4:32 am, saurabh singh saurab...@gmail.com wrote:
  After giving some thought,I think even radix sort may not be sufficient.
  Complexity of radix sort is O(k*n) where k is the number of buckets
  required to sort the given range.
  The number of buckets is proportional to the number of bits required to
  represent the *maximum number in the given range.*For our case the
 maximum
  number is O(n^2).Hence *the number of buckets required would be
  proportional to log(n^2) in the worst case.*
  Hence the worst case complexity for the given constraints using radix
 sort
  would be *O(n*(log n^2)) = O(n*logn).*
  This is no better than comparision sort.A slight optimization that we can
  make is to use a higher base which would reduce the number of buckets
  required but would add the cost of converting each number into  the
 higher
  base.
  Somehow I am getting convinced worst case O(n) algorithm may not be
  possible.Working on the mathematical proof.
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com
 wrote:
   @cegprakash They are n numbers lying in the range 1 to n^2.Not
 necessarily
   sorted.
   eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the
 problem)
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com
 wrote:
 
   The range 1 to n^2 is already sorted
 
   On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 
   wrote:
How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
--
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/-/PGgMdaIbGIsJ.
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] Sorting in O(n)

2012-05-04 Thread saurabh singh
@cegprakash They are n numbers lying in the range 1 to n^2.Not necessarily
sorted.
eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  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/-/PGgMdaIbGIsJ.
  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] Wrong Answer SPOJ

2012-04-25 Thread saurabh singh
I have been trying this problem which is from a past hacker cup.I am
getting wrong answer.http://www.spoj.pl/problems/NFACTOR/
My approach:
1.Count the number of prime factors of a number(trivial way)
for(int i=2;i*2=100;i++) number_of_factors[i]=1; //atleast 1 factor
that is 2
for(int i=3;i=100/2;i+=2) {
if(!prime[i]) continue;
number_of_factors[i]=1; //it is a prime so number of factors=1;
for(int j=2;i*j=100;j++){ number_of_factors[i*j]++; //increment number
of factors for i*j
prime[i*j]=false;
}
}

2. Seperately count numbers with j factors for all j in range(1,10) for
each i belonging to range(2,100)
3.Finding the cumalative sum for all  i in range 3,100 for all possible
factors 1 to 10

-THE CODE

#includestdio.h
#includeiostream
#includealgorithm
#includecmath
#includevector
#includecstdlib
#includestack
#includequeue
#includestring
#includecstring


#define PR(x) printf(#x=%d\n,x)
#define READ2(x,y) scanf(%d %d,x,y)
#define REP(i,a) for(int i=0;ia;i++)
#define READ(x) scanf(%d,x)
#define PRARR(x,n) for(int i=0;in;i++)printf(#x[%d]=\t%d\n,i,x[i])
using namespace std;
 int numFactors[101];
bool prime[101];
 int  numFac[10][101];
int main() {
for(int i=0;i10;i++) memset(numFac[i],0,sizeof(int)*101);
memset(numFactors,0,sizeof(numFactors[0])*101);
memset(prime,1,sizeof(prime[0])*101);
assert(0);
numFactors[2]=1;
for(int k=2;k*2=100;k++) {prime[k*2]=false;numFactors[k*2]=1;}
for(int i=3;i100/2+1;i+=2){
if(prime[i]==false)continue;
numFactors[i]=1;
for(int j=2;j*i=100;j++){
numFactors[j*i]++;
prime[i*j]=false;
}
}
numFactors[1]=0;
//PRARR(numFactors,100);
for(int i=2;i=100;i++)
if(numFactors[i]=10)numFac[numFactors[i]-1][i]=1;
for(int k=0;k10;k++) for(int i=3;i101;i++)
numFac[k][i]+=numFac[k][i-1];
long long t;
scanf(%lld,t);
int a,b,n;
while(t--){
scanf(%d %d %d,a,b,n);
if(n==0) {
if(a==1) printf(1\n);
else printf(0\n);
continue;
}
int ans=numFac[n-1][b]-numFac[n-1][a];
if(numFactors[a]==n) ans++;
printf(%d\n,ans);
}
}

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Required O(n) Algorithm

2012-04-22 Thread saurabh singh
@illya read the posts in the thread.Count sort is O(n) sorting
algorithm.The constraints in this algorithm is that the maximum value of
the array to be sorted should not be large.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Mon, Apr 23, 2012 at 5:25 AM, Ilya Albrekht ilya.albre...@gmail.comwrote:

 I'm not aware of any O(n) sort algorithms. Any (known) sort algorithm can
 have O(n) iff array is already sorted - kinda trivial case.

 So sort will not work for this task...


 On Wednesday, 18 April 2012 06:41:38 UTC-7, Dave wrote:

 @Viharri: A solution seems to require an O(n) sorting algorithm, and
 since sorting by comparison is O(n log n), the algorithm must use one of
 the other types of O(n) sorting algorithms. Since the data are not integers
 in a bounded range, I suggest using a radix sort, carrying along an array
 of indices. I.e., form an array of indices {0, 1, 2, ..., n-1} and perform
 the same data movements on it as on the original data. When the original
 data are sorted, then the array of indices will be the desired result.

 Dave

 On Wednesday, April 18, 2012 8:07:33 AM UTC-5, VIHARRI wrote:

 Can anybody give an O(n) algorithm for the following problem.

 Suppose if we have an array, I would like to construct an array with the
 elements which specify their corresponding position in the sorted array.

 For example if the array is { 0.87, 0.04, 0.95, 0.12, 0.36 } then the
 sorted array would be { 0.04, 0.12, 0.36, 0.87, 0.95 }.
 Then output array would be {3, 0, 4, 1, 2 }.

 Hope I'm clear...

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

 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: Find the maximum boxes which can fit each other?

2012-04-01 Thread saurabh singh
it depends on how you define the problem.finding the longest path in a
graph required O(N) where n is the total number of states.Dons
solution is not npc if i understand it right

On 4/1/12, bharat b bagana.bharatku...@gmail.com wrote:
 @don : but, finding longest path in a graph is NPC ... we should comeup
 with better solution 

 On Sat, Mar 24, 2012 at 10:25 PM, Don dondod...@gmail.com wrote:

 There is more to it than a longest increasing subsequence because the
 greater than relationship is not transitive.
 Don

 On Mar 24, 3:05 am, atul anand atul.87fri...@gmail.com wrote:
  ok you need to put box into a box...
  so first requirnment willl be to sort on the basis of area of box.
  after this bcoz you are adding one box into another...the box you are
  putting inside big box ..shud have base length less than a big box or it
  wont fit in...even if its area is smaller..
  now we reduced this problem of finding longest inc subsequence on the
 basis
  of base length.
  On 24 Mar 2012 13:14, Ratan success.rata...@gmail.com wrote:
 
 
 
   @atul can u plzz describe in detail the algo of modified subsequence
   prob used here i m nt able to get it ... though tried a lot
 
   On Sat, Mar 24, 2012 at 1:05 PM, atul anand atul.87fri...@gmail.com
   wrote:
it is modified longest increasing subsequence problem..
 
On 24 Mar 2012 12:26, Ratan success.rata...@gmail.com wrote:
 
You are given a lot of cuboid boxes with different length, breadth
 and
height. You need to find the maximum subset which can fit into each
other.
For example:
If Box A has LBH as 7 8 9
If Box B has LBH as 5 6 8
If Box C has LBH as 5 8 7
If Box D has LBH as 4 4 4
then answer is A,B,D
 
A box can fit into another only and only if all dimensions of that
 is
less than the bigger box. Also Rotation of boxes is not possible...
 
can ny1 suggest a good algo for this?
 
--
--
Ratan | 3rd Year | Information Technology | NIT ALLAHABAD
 
--
You received this message because you are subscribed to the Google
   Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
 
   --
   --
   Ratan | 3rd Year | Information Technology | NIT 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.- Hide quoted text -
 
  - Show quoted text -

 --
 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
 *
 * bagana.bharatku...@gmail.com

 Bharat B | M.Tech II  | C.S.E | IITM
 *
 *
 *Ph: +91 8056127652*

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




-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Slang Decoder chatBot... give a try...

2012-03-26 Thread saurabh singh
My impression is that the author is using  http://www.imified.com/ or a
similar platform which provides an interface to g-talk via very simple
PHP.The bad news is though that imified is going to be shut down soon as
they are not earning profit in this plan.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Mar 27, 2012 at 2:24 AM, Andreas Hahn www.gal...@googlemail.comwrote:

 Hi,

 I've tested your slang decoder bot and my first impression is: nice
 work, well done =)
 Unfortunetely the slang decoder's vocabulary isn't very big and most
 of the times I tested some exotic abbreviations, it just echoed my
 input =).

 But anyway, nice work. If you would like to expand the vocabulary of
 your bot, feel free to ask me, I would like to help you on that =).
 Furthermore, if you're planning to extend it someday to do some other
 useful stuff too, I would be grateful to be of help for you.

 But there is one question, I'd like to have answered: Do you use XMPP
 protocol to connect to Google Talk ? And which library do you use ?

 Thanks for answering.

 Regards
 Andreas

 2012/3/25 amrit harry dabbcomput...@gmail.com:
  Hi Friends i designed a chatbot for gmail. some time our friend use some
  slang terms in chat and we feel hesitation in asking the meaning of that
  slangs from friends so from now no need to do so or even googling it.
 just
  invite 'slangdeco...@gmail.com' for chat and query those slangs and get
  their meanings.
  sample data:
  lol
  rofl
  afk
  wtf
  brb
 
  GIVE IT A TRY
 
  i added a script to update database at midnight so currently some slangs
 are
  missing in database and those will be updated soon.
 
  Thanks Regards
  Amritpal Singh
 
  --
  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/-/kDUqpYummrAJ.
  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] [ DirectI ] Interview question

2012-03-24 Thread saurabh singh
I think not necessary consider the case 3 1 4 1 2 2 4
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Mar 24, 2012 at 10:53 PM, karthikeyan muthu 
keyankarthi1...@gmail.com wrote:

 if i'm not wrong .. we are to repeat this process till no more such pair
 is found.. rite?? this condition will come only if the given array gets
 sorted in ascending order .. so the solution is to sort the array
 O(nlogn)..



 On Sat, Mar 24, 2012 at 7:31 PM, Navin Kumar navin.nit...@gmail.comwrote:

 Given an array of integers, for each index i, you have to swap the value
 at i with the first value smaller than A[ i ] that comes after index i.
 An efficient solution expected.

  --
 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/-/an6YzWV-2xsJ.
 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: Interview question

2012-03-24 Thread saurabh singh
@amol I was trying to put forward the point that the o/p need not be
sorted.If you check the difference between time of  my and payal's message
it was a case of race condition.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Mar 25, 2012 at 6:54 AM, Gene gene.ress...@gmail.com wrote:

 This problem isn't carefully defined.  If you have 3,4,2 then 2 is the
 first value smaller and of higher index than both 3 and 4.  So which
 to swap with?

 On Mar 24, 10:01 am, Navin Kumar navin.nit...@gmail.com wrote:
  Given an array of integers, for each index i, you have to swap the value
 at
  i with the first value smaller than A[ i ] that comes after index i.
  An efficient solution expected.

 --
 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: Run Length Decoding... inplace

2012-03-23 Thread saurabh singh
what if we simply use the same char instead of '\0' that would reduce one
traversal?
(@utkarsh We discussed that earlier in lab.Did u found out the bug in this
approach?)
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Mar 23, 2012 at 6:38 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:

 I am considering that I am having total size of buffer that is maximum of
 output or input buffer and input is given in the buffer.

 My first approach of the solution was that
 1. first traverse whole array and then count total number of characters
 that will be present in whole array. O(n)
 2. fill the output array from rightmost side and start filling it until
 you reach 0th index. O(n)

 But it failed on this test case a1b1c4 here I could lost data b1 once I
 start filling character from right side.It faile because of characters
 whose count is 1.

 So I think just a change in algo will give me correct answer.
 1. first traverse whole array and then count total number of characters
 that will be present in whole array and in case if the character count is 1
 place '\0' in place of 1. O(n)
 2. imagining \0 as space .convert this problem to removing white space
 from strings  and compress it . Again can be done in O(n).
 3. fill the output array from rightmost side and start filling it until
 you reach 0th index. O(n)

 Please correct me if I am wrong.




 On Thu, Mar 22, 2012 at 9:13 AM, atul anand atul.87fri...@gmail.comwrote:

 @Ashish : a10 will be represented as aa . Here '1' and '0' are
 character type in the given input , so you need to convert it into numeric
 10.


 On Thu, Mar 22, 2012 at 1:09 AM, Ashish Goel ashg...@gmail.com wrote:

 Gene, Atul

 How would a string of say 257 or say 10 times a would be represented,
 will it be a10 or aascii of 10

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Wed, Mar 21, 2012 at 2:04 PM, atul anand atul.87fri...@gmail.comwrote:

 wasnt able to come up with an algo which would satisfy all the cases
 input like a1b1c4 here output length is equal to input length . till now i
 dont knw how to handle these type of input. :( :(

 On Wed, Mar 21, 2012 at 10:02 AM, atul anand 
 atul.87fri...@gmail.comwrote:

 @Gene : yes you are right , i misunderstood the problem . so m/m
 available is just enough to hold the output.
 thanks for correcting ... that would make this ques little interesting
 :) :)...i guess my first posted code can be modified to meet the
 requirement.
 i will post the updated code.

 On Tue, Mar 20, 2012 at 5:45 PM, Gene gene.ress...@gmail.com wrote:

 I don't think you're seeing the requirement completely.  The problem
 promises only that the output buffer will be big enough to hold the
 output.  You have made it huge.  I tried your code on an input of

 a1b1c6

 with the required output space of 8 characters (plus 1 for the C null
 character), and it printed

 cc

 and stopped.

 Last night I realized there is another approach that will work in all
 cases, so I deleted my post.  I guess it wasn't deleted on the server
 in your part of the world.

 You all can certainly work it out.  You can't just copy the input to a
 predetermined place in the buffer before processing it. It needs to be
 placed carefully, and it needs to be processed from both ends to a
 certain point in the middle.

 On Mar 20, 7:32 am, atul anand atul.87fri...@gmail.com wrote:
  using Gene logic ,  but we need to take care of number with more
 than 1
  digits , so updated gene's code is as follows :-
 
  #includestdio.h
  #define MAX 1000
 
  int copy(char *str,int len)
  {
  int max_len=MAX-1,i;
  for(i=len-1;i=0;i--)
  {
  str[max_len]=str[i];
  max_len--;
  }
  return max_len+1;
 
  }
 
  void runLength(char *str)
  {
  unsigned int j,k=1,loop=0,res_len=0;
  int i,n_start;
  char c;
  /*copying input to the end of the buffer*/
  n_start=copy(str,strlen(str));
 
  for(i=MAX-1;i=n_start;i--)
  {
  if(str[i]='0'  str[i]='9')
  {
  continue;
  }
  else
  {
  sscanf(str[i],%c%d,c,loop);
  for(j=0;jloop;j++)
  {
  str[res_len]=c;
  res_len++;
  }
  }
  }
  str[res_len]='\0';
  printf(\nDecoded Msg = %s\n,str);
 
  }
 
  int main()
  {
  char str[MAX];
  memset(str,0,MAX);
  printf(\nEnter String = );
  scanf(%s,str);
  runLength(str);
 
  return 1;
 
 
 
 
 
 
 
  }

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

Re: [algogeeks] Re: Run Length Decoding... inplace

2012-03-23 Thread saurabh singh
Yes u are correct...My bad...That obviously didn't made any sense

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Mar 23, 2012 at 7:49 PM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:

 yes if we use char instead of that place then again we will loss the data
 on the input a1b1c4


-- 
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] Maximum size square sub-matrix with all 1s

2012-03-14 Thread saurabh singh
 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 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.




-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-03-14 Thread saurabh singh
@sourabhThere are O(n^2) elements in the matrix of size nXn. Yes
we can find patterns in a substring with n elements in O(n) but can
you do that in O(sqrt(n)) (To complete your analogy),
Beside's can you allocate a 10^6X10^6 matrix in an array?


On 3/15/12, saurabh singh saurab...@gmail.com wrote:
 On 3/15/12, Sourabh Singh singhsourab...@gmail.com wrote:
 @rahul

 may be this will help you..

 /* Given a binary matrix, find out the maximum size square sub-matrix
 with
 all 1s.
1. O(n^3) sol is very obvious
2. O(n^2) sol [ this file]
3. O(n)   sol [ possible but we need to know tucker matrix, etc
 advanced
 set theory's]
 */


 #includeiostream
 #includeconio.h

 int b[6][6];
 using namespace std;
 main()
 { int i,j,t;
   int a[6][6]=
   { 0,0,0,1,0,1,
 0,1,1,1,0,0,
 1,1,1,1,0,1,
 0,1,1,1,1,0,
 1,0,0,1,0,0,
 0,1,0,1,1,0,};
   for(i=0;i6;i++)
   for(j=0;j6;j++)
   {   if(a[i][j]==1)
   {

 b[i][j]=min(min(b[i-1][j],b[i][j-1]),b[j-1][i-1])+1;
   }
   else
 b[i][j]=0;
   }
   for(i=0;i6;i++)
   {   for(j=0;j6;j++)
   {printf( %d,a[i][j]);
   }
   printf(\n);
   }
   printf(\n\n\n\n\n);
   for(i=0;i6;i++)
   {   for(j=0;j6;j++)
   {printf( %d,b[i][j]);
   }
   printf(\n);
   }
   getch();
   return 0;
 }


 On Wed, Mar 14, 2012 at 11:56 AM, Sourabh Singh
 singhsourab...@gmail.comwrote:

 @atul

 1) it won't work for large dimention's coz their is a limit to size of
 array we can declare on stack.
( which is typically 10^6 as far as i know :-)  ).

 2) the algo i m trying to find would work in linear time. while this one
 is more then O(n^2)
 fo rvery very large input this algo would be very very slow.. making
 it impractial..

 ( it's like if u can find substring's in linear time then why use an
 O(n^2) algo ;-) )

 NOTE: sry if m getting any fact's wrong m in mid of exam's (so a bit
 short
 on time to check implemention of  your algo right now )



 On Wed, Mar 14, 2012 at 9:07 AM, atul anand
 atul.87fri...@gmail.comwrote:

 @rahul: i have alreday explained it in the provided link.
 @sourbh : why it would not work for large dimension
 On 14 Mar 2012 19:39, rahul sharma rahul23111...@gmail.com wrote:

 @atul..plz tell me an example for square matrix...actually i faced it
 first tym...it executes...but explain plz..

 On Wed, Mar 14, 2012 at 6:56 PM, Sourabh Singh
 singhsourab...@gmail.com
  wrote:

 @atul

 Also the histogram algo and algo given by you can't work on very very
 big dimentions. say 10^5 x 10^5 matrix.
  but if we can find a DP then  we just need to keep 2 row's at a
 time.
 :-)



 On Tue, Mar 13, 2012 at 1:03 PM, Sourabh Singh 
 singhsourab...@gmail.com wrote:

 @atul

 read it ..

 it's good but more or less like the histogram algo.. i wanted a DP.
 approach..

 here is some of wat i heard from a senior in colg..

 1. at every index we can keep 4 variable

 ht: height of max rectangle possible at index above current
  wt width  

  hl:height of max rectangle possible at index left of  current
 wl:   
 


 now problem is which one to take for current... index



 On Tue, Mar 13, 2012 at 10:52 AM, atul anand
 atul.87fri...@gmail.comwrote:

 @ Sourabh: check solution i have posted in below link


 http://groups.google.com/group/algogeeks/browse_thread/thread/91a17f7c78c2319e/991d1c2625a62ff0?hl=enlnk=gstq=rectangle+of+max+sum+MS+Q#991d1c2625a62ff0



 On Tue, Mar 13, 2012 at 10:26 PM, Sourabh Singh 
 singhsourab...@gmail.com wrote:

 @ ALL

  finding square matrix is quite a standard question and nw an easy
 one as everyone knows the reccussence atul has given.
  but  i wanted to find max rectangle..

 i know there is a DP for it. in O(n^2). for nxn matrix..don't know
 the whole approach .but  here is what i remember..

 1. aproach is simple to keep track of max rectangle which can be
 formed from any point taking that point as top  left corner of max
 rectangle and
 proceed further down .

 can someone suggest how can be proceed further..


 [ NOTE: problem occurs mainly when their are more than one
 rectangles which can be formed from same point ]

 plz.. don't suggest the histogram method it's just a dirty way of
 avoiding to work on getting this DP right. :-)


 On Mon, Mar 12, 2012 at 11:29 PM, atul anand 
 atul.87fri...@gmail.com wrote:

 here is the recurrence for solving this

 R[i, j] = (M[i,j] == 0 ? 0 : 1 + min( R[i-1, j], R[i-1, j-1],
 R[i,,j-1] ) );


 On Tue, Mar 13, 2012 at 11:48 AM, rahul sharma 
 rahul23111...@gmail.com wrote:


  April 4, 2010

 Given a binary matrix, find out the maximum size square
 sub-matrix
 with all 1s

Re: [algogeeks] Re: Maximum height/depth of tree

2012-03-11 Thread saurabh singh
Quoting from wikipedia:
The *depth* (or *height*) of a tree is the length of the path from the root
to the deepest node in the tree.

However notice *length *is not defined and is left on the intuition.So *both
answers 2 and 3 are correct if we follow the above definition.* However the
next line on wiki entry says *A (rooted) tree with only one node (the
root) has a depth of zero. **So this line suggests the height should be 2.
*But in either case I don't think any sane computer scientist/programmer
will worry about whether the answer should be 2 or 3.After all the answer
differs by a constant factor.All depends on how you want to implement
it.Somewhat similar question can be whether 0 is a positive number?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Mar 11, 2012 at 12:44 PM, rahul sharma rahul23111...@gmail.comwrote:

 but according to the o/p it should be 3i also concerned from the data
 structure and algo book it is also giving same answer.so the
 height/depth is the number of nodes in largest pathis it rigt???


 On Sun, Mar 11, 2012 at 12:10 PM, Sonia Keys soniak...@gmail.com wrote:

 Correct is always whatever the specification says.  You may think
 something else is more conventional, or something else may seem right to
 you, but none of that matters if there are clear instructions otherwise.

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

 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] saurabh singh wants to chat

2012-03-10 Thread saurabh singh
---

saurabh singh wants to stay in better touch using some of Google's coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-8b1926b47c-1a94807712--9DQx1eW2o_LPykR-fUVx5lOG1s
You'll need to click this link to be able to chat with saurabh singh.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with saurabh singh, visit:
http://mail.google.com/mail/a-8b1926b47c-1a94807712--9DQx1eW2o_LPykR-fUVx5lOG1s

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into conversations
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Java question

2012-03-10 Thread saurabh singh
Is it possible items are removed from the truck too?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Mar 10, 2012 at 9:39 PM, shruthi sharma
shruthi.shar...@gmail.comwrote:

 I implemented it by using arraylist. I sorted the trucks according to the
 free space and when a load comes I iterated till the point, say j where I
 find a suitable space and then sorted it with the elements till j. I want
 to know if I can optimize it even further if possible. I want to know if
 there a best possible solution than what I implemented?

 --
 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] Floyd Warshall

2012-03-03 Thread saurabh singh
Its quite trivial..it just if there's a shorter way to reach from index j
and k by using any of the nodes as intermediate
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Mar 3, 2012 at 5:59 PM, shady sinv...@gmail.com wrote:

 Can someone explain Flyod Warshall algorithm, i am unable to understand
 how it works ?
 even a good link will suffice, i am not getting the intuition behind it.


-- 
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: Longest Path in A Graph

2012-02-22 Thread saurabh singh
In case cycle is present in the graph then we cant have a longest path in
the graph.Therefore the problem reduces to the longest path in a
tree.(Assuming the graph is connected).

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Feb 22, 2012 at 11:23 PM, Don dondod...@gmail.com wrote:

 Beware of cycles.
 Don

 On Feb 22, 6:05 am, krishna kishore kknarenkris...@gmail.com wrote:
  Hi Gentle Men, Can any Please let me know How to Find a LONGEST PATH in a
  Graph ( directed or Undirected but unweighted ).
  INPUT: we have to give the Source vertex and Destination Vertex.
  OUTPUT: it should include the LENGTH OF PATH and PATH as well.
  Remember the graph should not be weighted.
 
  Any suggestions are accepted for sure.
  And Thanks in Advance.
  --
 
  *Vignesh*

 --
 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: Finding closest double in a Btree

2012-02-20 Thread saurabh singh
@gene probably you are saying this on the basis of the subject of the
mail?Please read the problem statement stated in the mail.Even its  a B
tree doesn't effects the algorithm proposed by don which says *traverse
each node and keep track of minimum.*
So irrespective of the data structure used this solution is bound to
work
closest:
arguments: dataStructure T,int number

tmp:=getelem(T);
min=tmp.value
while( getelem returns non null values)
 do
 nxt:=getelem(T);

if(abs(nxt.value-number)min) then
tmp=nxt
min=nxt.value
done

done

return tmp

The nextelem function can be written according to the data structure used.

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Feb 21, 2012 at 6:06 AM, Gene gene.ress...@gmail.com wrote:

 Not to mention the subject line seems to be asking about B-Trees,
 which is no kind of binary tree, so the OP gets it wrong, too.

 On Feb 20, 7:28 pm, Dave dave_and_da...@juno.com wrote:
  @Don: By that measure, it also is trivial if the tree is a BST. You
  just find the largest node  x and the smallest one  x and choose
  between them.
 
  But since the original problem did not specify a BST, your solution is
  non-responsive. If I were grading a test, I'd have to count your
  solution as wrong, figuring that you do not know the difference
  between a binary tree and a binary search tree.
 
  Dave
 
  On Feb 20, 5:13 pm, Don dondod...@gmail.com wrote:
 
 
 
 
 
 
 
   Yes, I am assuming a binary search tree. The problem is trivial
   otherwise.
   If it is just a binary tree, you visit each node and keep track of the
   closest.
   Don
 
   On Feb 20, 5:02 pm, Dave dave_and_da...@juno.com wrote:
 
@Don: Aren't you assuming a binary _search_ tree? Only a binary tree
was specified by the OP.
 
Dave
 
On Feb 20, 10:44 am, Don dondod...@gmail.com wrote:
 
 Supraja,
 
 I think that your solution will work, but it does more work than is
 necessary. You don't need to traverse the entire tree.
 
 node findClosest(node root, double k)
 {
   node result = root;
   double diff = fabs(root-value - k);
   for(node loc = root; loc; loc = (loc-value  k) ? loc-left :
 loc-right)
 
   {
 double newDiff = fabs(loc-value - k);
 if (newDiff  diff)
 {
   result = loc;
   diff = newDiff;
 }
   }
   return result;
 
 }
 
 On Feb 20, 5:24 am, Supraja Jayakumar suprajasank...@gmail.com
 wrote:
 
  Hi
 
  Question is given a binary tree and a key K, code to find the
 node with the
  closest value.
 
  I'd be happy to receive some feedback about my solution too.
 
  Pls find the code below:
 
  class FindingClosestNodeInTree {
  private static double difference = 0.0;
  private static doule key = 0.0;
  int main() {
  BinaryTree bt;
  bt.insert(20.43);
  bt.insert(12.78);
  bt.insert(19.89);
  bt.insert(32.69);
  bt.insert(2.54);
  cout  Please provide the key value  endl;
  cin  key;
  const Node closestNode = closestValue(bt);
  cout   Node that has the closest value to
  closestNode.value;
  return 1;}
 
  const Node  closestValue(const BinaryTree node) {
  if(node==null)
  return;
 
  int val = node.value;
  int currDiff = val  key ? val-key:key-val;
  difference = currDiff  difference ? currDiff:difference;
  if(node.left!=null)
  closestValue(node.left);
  if(node.right!=null)
  closestValue(node.right);
  return difference;
 
  }
  }
 
  Thanks
  Supraja J- Hide quoted text -
 
- Show quoted text -

 --
 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] Data structure to implement mobile contacts list

2012-02-17 Thread saurabh singh
create a trie with an index number on each node where a name ends.The index
number can be the index of the database table where numbers are
stored,,,..or they can represent an offset in a file where the numbers are
stored.Possible problem-if a person with the same name has more than
one number.in that case we need to store instead of an index number an
array of index numbers...
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Fri, Feb 17, 2012 at 9:25 PM, Devansh Gupta devanshgupta...@gmail.comwrote:

 Which data structure will be the best one to implement contact list in
 mobiles?
 TRIE is a good choice but as we search for a name, it shows all possible
 names with that prefix. How it can be implemented with TRIE ?

 --
 Thanks and Regards
 *Devansh Gupta*
 *B.Tech Third 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.


-- 
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] nyone having pointer in c ebook..plz mail me...

2012-02-05 Thread saurabh singh
Kindly don't post more replies on this thread.This group is not for file
sharing.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Feb 5, 2012 at 3:12 PM, Veronica Sharma
sharma.veron...@gmail.comwrote:

 i have pdf of  pointers on c by Kenneth A Reek...but its 144 MB, cant send
 it on mail..


 On Sat, Feb 4, 2012 at 4:33 PM, rahul sharma rahul23111...@gmail.comwrote:


  --
 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: Spoj ABCPATH

2012-02-05 Thread saurabh singh
http://www.spoj.pl/problems/ABCPATH/
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Feb 5, 2012 at 11:18 PM, WgpShashank shashank7andr...@gmail.comwrote:

 @trinity tell the link of problem ?



 *Thanks
 Shashank Mani Narayan
 Computer Science  Engineering
 Birla Institute of Technology,Mesra
 ** Founder Cracking The Code Lab  http://shashank7s.blogspot.com/*

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

 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] someone pls explain the o/p??

2012-01-29 Thread saurabh singh
I once answered a similar question in stackoverflow.com
http://stackoverflow.com/questions/8586722/comparing-unsigned-char-and-eof/8586867#8586867
Hope
it helps...
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Jan 29, 2012 at 6:54 PM, Firoz Khursheed
firozkhursh...@gmail.comwrote:

 http://ideone.com/5uhz1
 it seems that
 -ve number is always converted to unsigned, but this time x=3  is greater
 why?


 On Sun, Jan 29, 2012 at 3:14 PM, Saurabh Yadav saurabh...@gmail.comwrote:

 may be because when you compare unsigned number with signed number ,the
 signed will changed to unsigned type and when signed will changed to
 unsigned type, it's MSB is one ,so  y will be greater than x

 i am not sure about the reason i gave !!


 On Sun, Jan 29, 2012 at 2:25 PM, Ashish Sachdeva 
 ashish.asachd...@gmail.com wrote:

 http://ideone.com/Ily5v

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




 --
 Thanks  Regards
 Saurabh Yadav

  --
 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: Represent a number in base of minus 2 ????

2012-01-29 Thread saurabh singh
Use a pen and paper:) Generate a few numbers in base -2 by hand.You
will get the logic.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Jan 29, 2012 at 11:44 PM, Zyro vivkum...@gmail.com wrote:

 0

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Online algorithm for cycle detection

2012-01-27 Thread saurabh singh
How to design an efficient data structure for a dag? The condition should
be there should be no cycle formed during insertion of edge.So this
condition for cycle needs to be checked at each insertion.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kurukshetra Online Debugging Prelims today

2012-01-26 Thread saurabh singh
Except few problems where the time limit is too tight a good algorithm is
equally good irrespective of the language.Yes C/C++ are faster than java
but in good competitions like topcoder,codeforces etc. language is not a
problem..For algorithm competitions you don't need a special
environment or editor even notepad and ideone will do.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jan 26, 2012 at 11:17 PM, prakash y yprakash@gmail.com wrote:

 Hi guys,
 I tried to participate in this contest and solved the first problem
 KDEBUG1 in Java. But I got time limit exceeded error.
 I observed that most of the coders use C/C++, and I know that Java is
 slower when compared to C/C++.

 My algorithm might be inefficient. But before that I just want to know
 whether Java is prefered or not especially when we compete in these types
 of coding contests.
 If not, please suggest me a good editor and programming environment.

 Please don't mind if it's not related to this group. But please help me,
 because I do not want to be disqualified next time.
 Thanks in advance.


 On Thu, Jan 26, 2012 at 1:02 PM, Rishi msrishiku...@gmail.com wrote:

 The online prelim round of  the Debugging event of *Kurukshetra *12, the
 annual technical symposium of* College of Engineering Guindy, Anna
 University* will be held on *26 January, 2012, 7.00 pm IST *at
 http://www.spoj.pl/KDEBUG/
 Participate in teams of three. Teams landing at top of this online
 contest will be directly qualified to the second round of onsite Debugging
 event of Kurukshetra 12.  Please share the info with your friends :)

  --
 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/-/20we4Ksf85QJ.
 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: Doubt regarding complexity (if comparison based sorting algorithm used)

2012-01-24 Thread saurabh singh
@ATUL..still we are not comparing elements among themselvesThe ordering
of elements is already known to us
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Jan 24, 2012 at 10:19 AM, atul anand atul.87fri...@gmail.comwrote:

 @Don : if i am not wrong ... American flag problem is closely related to
 radix sort not dutch flag.


 On Mon, Jan 23, 2012 at 11:16 PM, Don dondod...@gmail.com wrote:

 The Dutch Flag problem falls into the same category as radix sort,
 which is not a comparison-based sorting algorithm.
 Don


 On Jan 23, 1:26 am, atul anand atul.87fri...@gmail.com wrote:
  Hi all,
 
  as we all know that any sorting algorithm based on comparison model
 has
  lower bound of nlogn i.e Omega(nlogn).
  which can be proved mathematically.
 
  but as we all know dutch flag problem can sort 3 distinct elements (used
  repeatedly) in O(n) time.It is also based on comparison model but can
 sort
  in O(n) time.
  so how can we justify lower bound of sorting based on comparison model ,
  because dutch flag problem kinda violates that.
 
  please help me understanding the difference.
 
  Thanks

 --
 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] Binary Index Tree

2012-01-15 Thread saurabh singh
search problem japan
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Jan 15, 2012 at 4:23 AM, Mad Coder imamadco...@gmail.com wrote:

 Hi all, I was going through Binary Index Tree (BIT) tutorial through
 topcoder , although the concept is clear to me, I want to do some more
 practice questions. So it will be helpful if you provide me link of some
 questions of BIT in spoj.

 --
 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] kth largest element in an unsorted list

2012-01-14 Thread saurabh singh
nth order statistics http://en.wikipedia.org/wiki/Selection_algorithm
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Jan 14, 2012 at 8:23 PM, Piyush Grover piyush4u.iit...@gmail.comwrote:

 you can do it in nlogk or n+klogn time.

 create a min-heap tree of size k with first k nodes.
 Add k+1..n nodes in the tree. Everytime you insert a node in the tree
 check if it's greater than the root node. If yes remove
 root node and insert the new node (logk operations). So time complexity
 will be nlogk.

 another method with time complexity n+ klogn
 create a max heap tree of size n. O(n)

 keep on deleting the root node for k-1 operations by maintaining the heap
 property. Finally you will be left with the kth largest mode at the root.
 O(klogn)





 On Sat, Jan 14, 2012 at 7:58 PM, Ashish Goel ashg...@gmail.com wrote:

 Hi,

 how can we do so in O(n)
 forming a heap or a tree with each node keeping children in its left node
 still is nlogn


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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: Sorting for large data

2012-01-14 Thread saurabh singh
I would have told them to distribute the data in smaller logical
partitions.there is no way 10^80 objects can be handled.Even external
sort will take painfully enormous amount of time making it infeasible
practically.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Jan 15, 2012 at 1:02 AM, Abhishek Goswami zeal.gosw...@gmail.comwrote:

 @DAVE
 hmm I am agree with you that we  will not have that much huge
 data. This question came in my interview process and I was not able to
 figure out the solution of this issue.So I thought to check this forum


 On Sun, Jan 15, 2012 at 12:40 AM, Dave dave_and_da...@juno.com wrote:

 @Abhishek: Do you really mean 10 to the 80th power. I doubt if there
 is that much information in the world.

 Dave

 On Jan 14, 12:09 pm, Abhishek Goswami zeal.gosw...@gmail.com wrote:
  Hi,
  Could any point out me any algorithm and program  if we need to sort to
  large data
  like 10 ^ 80 with memory constraint. Suppose you have minimum memory
 like 4
  MB.
 
  I am not sure that this algo discussed or not but i was not able to
 find in
  this group.
 
  Thanks
  Abhishek

 --
 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] c output ??

2012-01-10 Thread saurabh singh
It's painful to see printf being accused for the (un) expected
output..The declaration of printf means that any data type can be
passed to it as argument.Inherently what printf does is print the bytes in
meaningful form according to the first argument which is a string.So its
impossible for printf to typecast arguments once they are passed they
appear the same way to printf...*A stream of bits from which it has to
extract the valid info.*Its the responsibility of the programmer to pass
the right data type with right format specifier...Just to complete my
answer http://www.ideone.com/CNkCo .
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Jan 10, 2012 at 2:29 PM, Rahul Verma rahulverma@gmail.comwrote:

 @amol this is not the behaviour of printf, its totally about the
 typecasting

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

 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] Binary Search Problem

2012-01-08 Thread saurabh singh
 not clear what you are trying to ask...can you quote exactly from the book?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal srn...@gmail.com wrote:

 In binary search,

 mid = start + (end-start)/2 is used to avoid overflow, as said by a book.

 why can't we use mid = (start + end)/2, it says this statement may result
 in overflow ?
 *
 Sanjay Kumar
 B.Tech Final Year
 Department of Computer Engineering
 National Institute of Technology Kurukshetra
 Kurukshetra - 136119
 Haryana, India
 Contact: +91-8053566286
 *

  --
 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: finding all combination

2012-01-07 Thread saurabh singh
Sorry for being offtopic but  yes if anyone proposes a polynomial time
algorithm(which can work for all cases) he is entitled to a prize money of
1 million. http://en.wikipedia.org/wiki/Millennium_Prize_Problems

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Jan 7, 2012 at 11:46 PM, Gene gene.ress...@gmail.com wrote:

 If you have an O(n^2) algorithm, you will be famous because you will
 have proven that P=NP.  As has been pointed out, this is the subset
 sum problem, well known to be NP hard.

 It is only weakly NP hard, though.  There is a simple pseudo-
 polynomial time DP algorithm.  Let S(n, k) be a boolean function true
 iff there is a subset of elements that sum to n using only elements
 1,2,...,k.

 Then S(n,k) = S(n,k-1) or S(n - a[k], k-1) for n,k0.  The base cases
 are S(0,k)=true for k=0 and S(n,0)= false for n0.  The intuition
 here is you either skip usiong the k'th item in the subset or use
 it.

 This just tells you whether a subset exists.  It's easy to find the
 subset elements with back pointers in the DP table, which will form a
 tree rooted at S(n, N) where the array has N elements.  Each root-leaf
 path in the tree will be a valid subset.

 This algorithm is polynomial in the _size_ of the elements, which is
 exponential time by the normal definition, but can be useful if data
 are small.  That's why it's called pseudo-polynomial time.



 On Jan 3, 12:26 pm, atul anand atul.87fri...@gmail.com wrote:
  There is integer array like {1,2,4,5,6,1,2,4,3,5,7,2,1}. I want to find
 the
  possible combination which will sum to 4.
  input : {1,2,4,5,6,1,2,4,3,5,7,2,1}
  output : {1,1,2}, {2,2}, {3,1}, {1,2,1}{4}...etc which make the sum as 4
 
  any approach better than O(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
 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: finding all combination

2012-01-06 Thread saurabh singh
@all Yes it is possible to find the solution using 0/1 knapsack.The
approach would be similar as in case of LCS problem when many LCS are
possible.Though the implementation could be a bit difficult.For each
subproblem when the choice of dubproblems become equally beneficial start a
new thread with both the subproblems...
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Jan 7, 2012 at 2:01 AM, Don dondod...@gmail.com wrote:

 Given an array A[n], start by sorting the array.
 Then do something like this:

 int result[n];
 int size=0;

 void findSubset(int sum, int position=0)
 {
if (sum == 0) output(result, size);
for(int i = position; i  n; ++i)
{
if (A[i]  sum) break;
result[size++] = A[i];
 findSubset(sum-A[i], i+1);
 --size;
}
 }

 Call it like this: findSubset(4);

 Don

 On Jan 3, 5:26 am, atul anand atul.87fri...@gmail.com wrote:
  There is integer array like {1,2,4,5,6,1,2,4,3,5,7,2,1}. I want to find
 the
  possible combination which will sum to 4.
  input : {1,2,4,5,6,1,2,4,3,5,7,2,1}
  output : {1,1,2}, {2,2}, {3,1}, {1,2,1}{4}...etc which make the sum as 4
 
  any approach better than O(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
 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: check Similar array

2012-01-05 Thread saurabh singh
Some very nice approaches have been presented but I still feels for
practical situations its better to sort and compare..All other
algorithms presented above restricts the max value for an element in the
array.In case the maximum value is small,we can simply count sort,and the
algorithm will still be O(N) (Much simpler and immune to problems such as
finite word size)


Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jan 5, 2012 at 5:17 PM, atul anand atul.87fri...@gmail.com wrote:

 @Shashank :  as i have mentioned in the question , no sorting allowed.
 if question would have allowed sorting then why not sort both array and
 compare it would be much simpler and no need of doing costlier operation
 like finding power.

 complexity = O(nogn) + O(mlogm) + O(n)



  --
 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] A graph problem

2012-01-05 Thread saurabh singh
This problem is taken from www.codeforces.com.What can be the possible
approaches??

A smile house is created to raise the mood. It has *n* rooms. Some of the
rooms are connected by doors. For each two rooms (number *i*and *j*), which
are connected by a door, Petya knows their value *c**ij* — the value which
is being added to his mood when he moves from room *i* to room *j*.

Petya wondered whether he can raise his mood infinitely, moving along some
cycle? And if he can, then what minimum number of rooms he will need to
visit during one period of a cycle?
 Input

The first line contains two positive integers *n* and *m* (), where *n* is
the number of rooms, and *m* is the number of doors in the Smile House.
Then follows the description of the doors: *m* lines each containing four
integers *i*, *j*, *c**ij* и *c**ji* (1 ≤ *i*, *j* ≤ *n*, *i* ≠ *j*, - 104≤
*c**ij*, *c**ji* ≤ 104). It is guaranteed that no more than one door
connects any two rooms. No door connects the room with itself.
 Output

Print the minimum number of rooms that one needs to visit during one
traverse of the cycle that can raise mood infinitely. If such cycle does
not exist, print number 0.
 Sample test(s)
 input

4 4
1 2 -10 3

1 3 1 -10
2 4 -10 -1
3 4 0 -3

 output

4

 Note

Cycle is such a sequence of rooms *a*1, *a*2, ..., *a**k*, that *a*1 is
connected with *a*2, *a*2 is connected with *a*3, ..., *a**k* - 1 is
connected with *a**k*,*a**k* is connected with *a*1. Some elements of the
sequence can coincide, that is, the cycle should not necessarily be simple.
The number of rooms in the cycle is considered as *k*, the sequence's
length. Note that the minimum possible length equals two.




Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: A graph problem

2012-01-05 Thread saurabh singh
Yes I also initially thought soBut how do we take into consideration
the edge weights??The cycle can include such edges whose total cost may
come negative.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Thu, Jan 5, 2012 at 10:01 PM, karthikeyan muthu 
keyankarthi1...@gmail.com wrote:

 find the size of smallest cycle in the given graph ... tarjan should do
 the trick.. dfs basically ... :)


 On Thu, Jan 5, 2012 at 7:02 PM, WgpShashank shashank7andr...@gmail.comwrote:

 @Saurabh DFS Should Work Here, Start from any room i , visit next
 room connected to it .. then to this room   so on , once you back track
 you will back to the starting node ,this way you can find out .min.umber of
 room he need to visit will be 2 times of traversal isn't it ?


 posting the soln in hurry :), i know may have some bugs , will discuss
 after some time.

 Thanks
 Shashank

 --
 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/-/El6uttSxuA0J.
 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] finding all combination

2012-01-03 Thread saurabh singh
Most probably noThis is the subset sum problem which is proven NP
complete...Even if a better solution than n^2 exists it won't work for all
cases
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD




On Tue, Jan 3, 2012 at 4:56 PM, atul anand atul.87fri...@gmail.com wrote:

 }
 output : {1,1,2}, {2,2}, {3,1}, {1,2,1}{4}...etc which make the sum as 4


-- 
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: DP problems in SPOJ

2012-01-03 Thread saurabh singh
@atul in case you are considering indexing from 1 then your for loop shud
be *for(i=1 *.
Its more obvious this way that you are indexing from 1.(Although
doesn;t makes any difference to the overall objective)


Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, Dec 31, 2011 at 8:25 PM, atul anand atul.87fri...@gmail.com wrote:

 @Lucifier :

 i wrote  for (int i=0; i = 9; ++i) because i was considering index from
 1 to n
 not 0 to n-1;

 you are considering from 0 to n-1. so both are 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.


-- 
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] Invitation - Abacus'12 Online Programming Contest

2012-01-03 Thread saurabh singh
Kindly mail any further queries to the author of this mail directly
@kashyap Thanx for sharing the info...


*THREAD CLOSED-*

Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Tue, Jan 3, 2012 at 9:33 PM, cibe hariharan k.cibehariha...@gmail.comwrote:

 well what is the last date for registration dude


 On Tue, Jan 3, 2012 at 9:08 PM, Kashyap Krishnakumar kashyap...@gmail.com
  wrote:

 Hi,
  I invite you to take part in *CODE 
 MODULE*http://www.spoj.pl/ABACUS12/,
 the *Online Programming Contest of *Abacus'12 http://www.abacus.org.in/,
 organised by the Department of Computer Science and Engineering, College of
 Engineering Guindy, Anna University, Chennai. Details about the contest can
 be found here http://abacus.org.in/online-programming-contest/. *
 Register here http://abacus.org.in/opc/* to participate as well as to
 get updates and reminders about it. The contest will take place on *Jan
 15, 2012 at 9 PM IST*. To find out the time and date in your time zone,
 check out this 
 linkhttp://www.timeanddate.com/worldclock/fixedtime.html?msg=CODE+MODULE+-+Online+Programming+Contest+of+Abacus+12iso=20120115T21p1=1648
 .

 *Prize Money*
 First Place - $200
 Second Place - $100

 Regards,
 Kashyap.K,
 III year, B.E CSE,
 College of Engineering Guindy,
 Anna University,
 Chennai.

 --
 If you've never failed, you've never lived!

  --
 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] check Similar array

2012-01-03 Thread saurabh singh
Why would xoring fail?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Jan 4, 2012 at 9:56 AM, SAMM somnath.nit...@gmail.com wrote:

 I think this may works . needs verification.

 For the given array (3 5 2 5 2)
 For +ve number (N) take the sum from 1 to N .
 For -ve number (N) take the sum from -1 to N .
 And take take the cumulative sum ... For this array it comes 42 .
 Similarly check the sum for the second array . If it is same then we r
 done .

 On 1/3/12, atul anand atul.87fri...@gmail.com wrote:
  There are two arrays.
  int arr1[5] = { 3, 5, 2, 5, 2}
  int arr2[5] = { 2, 3, 5, 5, 2}
  The arrays will be called similar if they contain same number of elements
  equally.
  Write the pseudo code to check this ?
  not allowed to use sorting and hashtable.
 
  naive approach O(n^2)
 
  NOTE: Xoring , sum wont work.
 
  we can use O(n) space , using index as elements in the array. but if it
 has
  negative number then it will fail for eg arr1 has -1,...  and arr2 has
  1,.
 
  --
  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.
 
 


 --
 Somnath Singh

 --
 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] check Similar array

2012-01-03 Thread saurabh singh
Ok got itwill fail for the cases where the xor in the arrays
individually come to 0..
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Jan 4, 2012 at 10:13 AM, atul anand atul.87fri...@gmail.com wrote:

 how its 42??..didnt get it :(

  --
 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: check Similar array

2012-01-03 Thread saurabh singh
@sharad Your approach limits the size of array to be very small(as well as
the elements of the array to be small).Else the product will become too big
to be held in an array.Same applies with samm's solution too though in his
case we can be more liberal with element's value..


Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Jan 4, 2012 at 11:11 AM, sharad dixit sharad.emine...@gmail.comwrote:

 Can we use concept of prime number as fundamental theorem of arithmetic
 i.e every number has a unique factorization into primes (
 http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic) and then
 multiply them together.

 e.g
  A1[3] = { 2,3,4}   =  secondprime*thirdprime*forthprime = 2 * 3 * 5 = 30
  A2[3] = { 3,2,4}   =  3rdprime * 2ndprime* 4thprime = 3 * 2 * 5 =30

 On Wed, Jan 4, 2012 at 11:00 AM, rahul patil 
 rahul.deshmukhpa...@gmail.com wrote:


 @samm: Rather than adding numbers could we add squares(or cube) of
 numbers which could also be done in linear time?


 On Wed, Jan 4, 2012 at 10:56 AM, rahul patil 
 rahul.deshmukhpa...@gmail.com wrote:

 @samm: Ur solution is great. It could be used to tell that arrays are
 not similar, in linear time. But cant tell that they are 100% similar
 ur solution fails for the simple case.
 arr1: 3,4
 arr2: 5,1

 On Wed, Jan 4, 2012 at 10:49 AM, SAMMM somnath.nit...@gmail.com wrote:

 No it's not if u use the AP series mathematical formula n(n+1)/2..
 Then it will be of O(n).

 --
 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,
 Rahul Patil




 --
 Regards,
 Rahul Patil

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




 --
 -Sharad Dixit
  B.Tech(IT)
  Indian Institute of Information Technology Allahabad

 -
 We aim above the mark to hit the mark.
 ~ Ralph Waldo Emerson

  --
 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 output????

2012-01-03 Thread saurabh singh
@all.Your explanations work because probably all of you are using a
compiler that's behaving in the same way.Don't conclude from what you
see...The compiler is free to store the constant strings the way it
wants.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Wed, Jan 4, 2012 at 12:13 PM, Rahul raikra...@gmail.com wrote:

 it's near to a common mis conception that string liberals are in data
 sections of THE PROGRAM


 PLEASE READ THE FILE
 a.out.h

 and find the difference between initialized data and non initialized data

 On 9/6/11, Sandy sandy.wad...@gmail.com wrote:
  String constants (literals) are saved into the .data section of the
 program,
   Here is the sample program to show that.  if() is essentially comparing
 the
  addresses of two pointers which is same.
 
  int main()
  {
  char *p=persons;
  char *q=persons;
  char *r=persons;
  char *s=persons;
   printf(%x %x %x %x\n,p,q,r,s);
  if(p==persons)
  printf(technical %s,p);
  else
  printf(true %s,p);
  return 0;
  }
  -
  Output:
  403021 403021 403021 403021
  technical persons
 
  On Tue, Sep 6, 2011 at 9:04 PM, sivaviknesh s sivavikne...@gmail.com
 wrote:
 
 
  main()
  {
  char *p=persons;
  clrscr();
  if(p==persons)
  printf(technical %s,p);
  else
  printf(true %s,p);
  return 0;
  }
 
  ..op : technical persons ..plz explain .. how come it works like an
 strcmp
  operation???
  --
  Regards,
  $iva
 
   --
  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.
 
 
 
 
  --
 
  *Sandeep Kumar,*
   ( Mobile +91-9866507368
 
  *“I believe in smart work, Believe Me”*
 
  --
  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] addition of two numbers without using logical or arithmetic operators

2011-12-22 Thread saurabh singh
Already discussed n times...nth discussion not required
http://www.mail-archive.com/algogeeks@googlegroups.com/msg27861.html Check
this link.

On Thu, Dec 22, 2011 at 10:59 AM, Deepika Srinivisan 
deepikasrini1...@gmail.com wrote:

 @:)) hello frnds
Can u pls help me out in writing a pgm how to add two numbers
 in C language without using both logical and arithmetic operators

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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] Re: given a stream of numbers FIND MEDIAN

2011-12-16 Thread saurabh singh
If the input stream does not allows random access(and we cant store the
elements in auxillary memory) then there is no way to find in O(1)(Can be
done non-deterministically though in O(1)) .
If the above two constraints are not present then the problem is trivial
enough to be discussed.

On Fri, Dec 16, 2011 at 2:15 PM, hardbug hard...@gmail.com wrote:


 I guess median would be the middle element of the array(A[n/2]) where
 n is odd, and if the array size is even then you might return the mean
 of two middle values.

 On Dec 16, 12:26 pm, Sangeeta sangeeta15...@gmail.com wrote:
  You are given a stream of numbers which can be positive or negative.
  You are
  required to provide an operation FIND MEDIAN..which when invoked
  should be
  able return the median of the numbers in stream (in sorted order) in
  O(1)
  time.

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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] Re: convert into palindrome

2011-12-15 Thread saurabh singh
Sorry for replying late...ya posted the reply in hurry.But it appears that
finally it has been resolved what i meant to say in my original post.

On Thu, Dec 15, 2011 at 6:38 PM, Mohit kumar lal kumarmohit...@gmail.comwrote:

 @Lucifer- thnks got ur logic...:)


 On Thu, Dec 15, 2011 at 12:07 PM, Lucifer sourabhd2...@gmail.com wrote:

 Correction:

 for NAN :
 N(IT)A + TI + N = NITATIN


 On Dec 15, 11:33 am, Lucifer sourabhd2...@gmail.com wrote:
  @topcoder..
 
  String: NITAN
 
  RevStr: NATIN
 
  LCS ( NITAN, NATIN) = { NIN , NAN }
 
  Here all we care about the count which is 2. Hence, 2 additions would
  be required to convert it into a palindrome..
 
  The possible palindromes would be:
  for NIN :
  N + AT + I(TA)N = NATITAN
 
  for NAN :
  N + TI+ A(IT)N = NATITAN
 
  On Dec 15, 11:24 am, top coder topcode...@gmail.com wrote:
 
 
 
 
 
 
 
   @Mohit
 
   Suppose for example
 
   String: NITAN
   LCS(Longest Common Subsequence) : NIN
 
   How do you get the palindrome with it?
 
   On Dec 15, 3:47 am, Lucifer sourabhd2...@gmail.com wrote:
 
@Mohit
 
I think what he meant is 2* strlen(Input String) - 2* (Length of
LCS)
 
On Dec 15, 3:44 am, Mohit kumar lal kumarmohit...@gmail.com
 wrote:
 
 @saurabh-as by the above example LCS of HELLO and its inverse
 would be
 LL and how can we form the word HELLOLLEH with it ...
 and is your ans for the word NITAN is NITATIN ...?
 
 On Wed, Dec 14, 2011 at 8:39 PM, saurabh singh 
 saurab...@gmail.com wrote:
  Find the LCS of string with its reverse
 
  On Wed, Dec 14, 2011 at 8:33 PM, top coder 
 topcode...@gmail.com wrote:
 
  Given a word, convert it into a palindrome with minimum
 addition of
  letters to it. letters can be added anywhere in the word.
 
  . for eg if hello is given, result should be hellolleh
 
  --
  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.
 
  --
  Saurabh Singh
  B.Tech (Computer Science)
  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.
 
 --
 Mohit kumar lal
 rit2009014
 IIIT ALLAHABAD
 contact@9454681805
 kumarmohit...@gmail.com
 mohitkumar...@yahoo.com
 rit2009...@iiita.ac.inhttp://
 profile.iiita.ac.in/rit2009014-Hidequoted text -
 
- Show quoted text -

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




 --
 Mohit kumar lal
 rit2009014
 IIIT ALLAHABAD
 contact@9454681805
 kumarmohit...@gmail.com
 mohitkumar...@yahoo.com
 rit2009...@iiita.ac.in
 http://profile.iiita.ac.in/rit2009014

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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] doubt in spoj 8473 ways

2011-12-15 Thread saurabh singh
Post the formatted code too.(With proper indents)Then it would be easier
for others to work on it,

On Thu, Dec 15, 2011 at 11:47 PM, anubhav raj anubhaw@gmail.com wrote:

 we have to submit it in 120 byte cn ne 1 tl me dat whr z the chances of
 further byte reduction in this code.
 #includestdio.h
 #define s(n) scanf(%d,n)
 #define I int
 I a[14][14];I d(I m,I n){I s=a[m][n];I k;if(!m||!n)k=1;else
 if(s)k=s;else{k=d(m-1,n)+d(m,n-1);s=k;}return k;}main(){I
 t,n,k;s(t);while(t--){s(n);k=d(n,n);printf(%d\n,k);}}

 tnx in advnce

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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] Complexity

2011-12-14 Thread saurabh singh
Introduction to Algorithms Coreman

On Wed, Dec 14, 2011 at 8:21 PM, Shashank Jain shashan...@gmail.com wrote:

 I need to study both space and time complexities. What is the best source?

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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] Re: Find Largest number in log(n)

2011-12-12 Thread saurabh singh
@all..Well I am no expert but my logic says its impossible to pick the best
unless and untill you look at each and every individual.Isn't this logic
enough?


On Tue, Dec 13, 2011 at 12:32 AM, Ankur Garg ankurga...@gmail.com wrote:

 By Max Heapify I thought u meant to say u are making a Max Heap .. In case
 you use Coreman Definition Of max Heapify it just heapifies assuming the
 heap has been formed, But u need to make a max Heap first dude :)

 P.S- Clarify your concepts before posting the link :(


 On Tue, Dec 13, 2011 at 12:11 AM, Dipit Grover dipitgro...@gmail.comwrote:

 ^it cant get better than O(n) apparently. Just applying max-heapify once
 would not yield the max element. You need to construct a heap for it, which
 is no less than O(n).

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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] Re: Number Theory (Power of 3 )

2011-12-07 Thread saurabh singh
Originaly problem rules out the use of log.Moreover log (or any floating
point operations) take lot of hardware time as they are emulated on the
floating point environment on most machines.Thirdly precision problem for
higher values of n may cause your solution to give wron g answers,,,

On Wed, Dec 7, 2011 at 11:54 PM, tech coder techcoderonw...@gmail.comwrote:

 what about this   log(base 3 n)  is of  integral type then n is a power of
 3


 On Mon, Dec 5, 2011 at 11:36 PM, Dave dave_and_da...@juno.com wrote:

 @Carl: You can generate the constants the first time the procedure is
 called. There is no need to do them every time. So the first call
 would be O(wordsize) but subsequent calls are O(1).

 Dave

 On Dec 5, 10:28 am, Carl Barton odysseus.ulys...@gmail.com wrote:
  Sorry, I was being a bit vague. I meant what would the time complexity
 be
  then?
  As I understand your Constant time is Dependant on the constant pre
  computation you do, which is no longer the case when you generalise
 
  On 5 December 2011 16:14, Dave dave_and_da...@juno.com wrote:
 
 
 
   @Carl: Of course. For any given word size, extend the tables of powers
   of 2 and of 3 and change the for loop limit.
 
   Dave
 
   On Dec 5, 9:36 am, Carl Barton odysseus.ulys...@gmail.com wrote:
Ah I see, in which case could you not generalise your solution for
 all
integers?
By taking into account the size of words on the computer for
 example?
 
On 5 December 2011 15:09, Dave dave_and_da...@juno.com wrote:
 
 @Carl: Yes, as coded, my algorithm is for 32-bit integers. But the
 original poster asked for a solution using bit manipulation, and
 modulus and division are arithmetic operations, not bit
 operations.
 
 Dave
 
 On Dec 5, 8:56 am, Carl Barton odysseus.ulys...@gmail.com
 wrote:
  @Dave Yours only works for a certain subset of all possible
 powers
   or 3
  doesn't it? So WgpShashank's would be more general?
 
  On 5 December 2011 14:30, Dave dave_and_da...@juno.com wrote:
 
   @WgpShashank: Yours is an O(log n) solution. Mine is O(1).
 
   Dave
 
   On Dec 5, 6:21 am, WgpShashank shashank7andr...@gmail.com
 wrote:
@SAMMM  have a look
 
* *solution is to keep dividing the number by 3, i.e, do n
 = n/3
iteratively. In any iteration, if n%3 becomes non-zero and
 n is
   not 1
   then
n is not a power of 3, otherwise n is a power of 3
 
check it out ?http://codepad.org/863ptoBE
 
Thanks
Shashank
Computer Science
BIT Mesrahttp://
  www.facebook.com/wgpshashankhttp://shashank7s.blogspot.com/
 
   --
   You received this message because you are subscribed to the
 Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to
 algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 --
 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.




 --
 *

  Regards*
 *The Coder*

 *Life is a Game. The more u play, the more u win, the more u win , the
 more successfully u play*

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




-- 
Saurabh Singh
B.Tech (Computer Science)
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

  1   2   3   4   >