Re: [algogeeks] I am new to CPP STL please help

2013-05-16 Thread Prakhar Jain
strcmp is for C-style strings. Use in-built compare function of C++ strings ( http://www.cplusplus.com/reference/string/string/compare/ ), or why not simply '==' operator. -- Prakhar Jain IIIT Allahabad B.Tech IT 4th Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha

Re: [algogeeks] how does this code achieve SIGSEGV

2012-12-21 Thread Prakhar Jain
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

Re: [algogeeks] Flipkart test

2012-10-09 Thread Prakhar Jain
to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -- Prakhar Jain IIIT Allahabad B.Tech IT 4th Year Mob no: +91 9454992196 E-mail: rit2009

Re: [algogeeks] Inversion problem

2012-07-08 Thread Prakhar Jain
You can use either Merge sort or BIT(refer TopCoder tutorial). -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com On Sun, Jul 8, 2012 at 11:31 AM, Navin Kumar algorithm.i...@gmail.comwrote: Let A[n

Re: [algogeeks] flipkart question

2012-07-07 Thread Prakhar Jain
Label 3 of the faces with 0 and other 3 faces with 6. -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com On Sat, Jul 7, 2012 at 12:52 AM, Hraday Sharma hradaysha...@gmail.comwrote: You are given 2 dice

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread Prakhar Jain
be the peak element. So, the peak element is always there in the array even if it is sorted in any order. -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com On Sun, Jun 24, 2012 at 2:26 PM, adarsh kumar algog

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread Prakhar Jain
I think it can't be done in O(log n) as per given problem constraints. It can be done in O(log n) if additional information that array is bitonic is given. -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com

[algogeeks] Suggestion needed

2012-06-17 Thread Prakhar Jain
Hello everyone, Please anyone suggest that what books,sites,etc. should be preffered while preparing for topics such as networking, dbms, os, aptitude for placements. Any advice would be helpful! (Sorry for posting not related to group) Thanks. -- Prakhar Jain IIIT Allahabad

Re: [algogeeks] Re: Power(n^n)

2012-06-14 Thread Prakhar Jain
Typo in this problem statement. K is not less than or equal to 1000. Only N=1000. K can be as big as 1000^1000,i.e. 1000 digits. -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com On Tue, Jun 12, 2012 at 12

Re: [algogeeks] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-06 Thread Prakhar Jain
@abhishek...Plz share the link here.Thanks -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com On Wed, Jun 6, 2012 at 5:32 PM, amrit harry dabbcomput...@gmail.com wrote: @abhishek pls send link me too

[algogeeks] Allocating memory of size 0

2012-06-02 Thread Prakhar Jain
Hi everyone, Someone plz explain why this C code works fine as memory allocated is of 0 size... main() { int *p=malloc(0); *p=2566; printf(%d\n,*p); getchar(); } -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in

Re: [algogeeks] MODULUS

2012-02-21 Thread Prakhar Jain
to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd Year Mob no: +91 9454992196 E-mail: rit2009...@iiita.ac.in jprakha...@gmail.com -- You received

Re: [algogeeks] determining if frequency is greater than n/2

2012-02-09 Thread Prakhar Jain
But in this post, we don't have prior information about what can be possible majority element. According to my question, we know that either x is the majority element or there is no majority element. Can we use that information to reduce complexity to O(log n)..??? -- You received this message

[algogeeks] determining if frequency is greater than n/2

2012-02-08 Thread Prakhar Jain
Hello everyone, suppose we have an array of size n and a number, say x, and we have to determine whether the number x is present in the array more then n/2 times or not? can we have an O(log n) algo for determining it..?..pls help...!!! -- -- Prakhar Jain IIIT Allahabad B.Tech IT 3rd

Re: [algogeeks] Finding the mode in a set of integers

2010-04-14 Thread Prakhar Jain
If m thinking right, That works if mode occurs =n/2 times in the array Best, Prakhar Jain http://web.iiit.ac.in/~prakharjain/ On Wed, Apr 14, 2010 at 8:12 PM, sharad kumar aryansmit3...@gmail.comwrote: can we make use of majority VOTE ALGORITHM? On Wed, Apr 14, 2010 at 4:14 PM, Gauri gauri

Re: [algogeeks] Implement a queue using a stack

2010-03-22 Thread Prakhar Jain
By a do u mean a single stack ? Otherwise if you use 2 its v simple Best, Prakhar Jain http://web.iiit.ac.in/~prakharjain/ On Mon, Mar 22, 2010 at 12:56 AM, Pushpesh Gupta pushpes...@gmail.comwrote: How is it possible to implement a queue using a stack only? -- You received this message

Re: [algogeeks] Implement a queue using a stack

2010-03-22 Thread Prakhar Jain
A better version exists where amortized order is (1) for both opreations Best, Prakhar Jain http://web.iiit.ac.in/~prakharjain/ On Mon, Mar 22, 2010 at 6:56 PM, Brian brianfo...@gmail.com wrote: How is it possible to implement a queue using a stack only? Interesting, but tricky... You

Re: [algogeeks] Implement a queue using a stack

2010-03-22 Thread Prakhar Jain
on an avg... say if you insert 10 elemets n remove 10. you consume O(20) Best, Prakhar Jain http://web.iiit.ac.in/~prakharjain/ On Mon, Mar 22, 2010 at 7:39 PM, vikrant singh vikrantsing...@gmail.comwrote: Can u xplain what amortized means? On Mon, Mar 22, 2010 at 7:32 PM, Prakhar

Re: [algogeeks] Kth element in BST without static/global variable or function argument

2009-12-09 Thread Prakhar Jain
Do an iterative inorder traversal and stop at k ? Best, Prakhar Jain http://web.iiit.ac.in/~prakharjain/ On Thu, Dec 10, 2009 at 7:38 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: You can maintain the size. or it can be computed in at worst linear time. In first method, the only

[algogeeks] Re: Spell Checker

2009-07-31 Thread Prakhar Jain
, Prakhar Jain prakh...@gmail.com wrote: Hi, How would you design a dictionary so that you can make a spell checker ? You would have to suggest alternates... Best, Prakhar -- Potential is not what U have, its what U think U have!!! It is better to worn out than rust

[algogeeks] Re: Spell Checker

2009-07-31 Thread Prakhar Jain
Alternatives as in alternate spelling suggestions Prakhar On Fri, Jul 31, 2009 at 7:03 PM, Vikram Sridar vikramsridar...@gmail.comwrote: Alternatives?? what way?? In terms of implementation or providing some other functionalities?? --~--~-~--~~~---~--~~

[algogeeks] Spell Checker

2009-07-30 Thread Prakhar Jain
Hi, How would you design a dictionary so that you can make a spell checker ? You would have to suggest alternates... Best, Prakhar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: Fwd: [algogeeks] Re: Binary search

2009-03-04 Thread Prakhar Jain
I would call search() not binsearch() search() find any index and then iterates sequentially till the highest index. Prakhar On Wed, Mar 4, 2009 at 4:27 PM, Kapil navka...@gmail.com wrote: @Prakhar how would you ensure that this is highest index On Mar 1, 3:05 pm, Prakhar Jain prakh

Re: Fwd: [algogeeks] Re: Binary search

2009-03-04 Thread Prakhar Jain
no the order is log(n) On Wed, Mar 4, 2009 at 4:45 PM, sharad kumar aryansmit3...@gmail.com wrote: but commplexity is O(n2) rite??wat about my solution?? On Wed, Mar 4, 2009 at 4:32 PM, Prakhar Jain prakh...@gmail.com wrote: I would call search() not binsearch() search() find any index

[algogeeks] Re: Binary search

2009-03-04 Thread Prakhar Jain
?? On Wed, Mar 4, 2009 at 6:48 PM, Prakhar Jain prakh...@gmail.com wrote: see its log(n) + k where k=the number of duplicates of the element being searched. For log(n), you can continue till your high comes on the element u desire and not low. On Wed, Mar 4, 2009 at 6:45 PM, sharad kumar

Fwd: [algogeeks] Re: Binary search

2009-03-01 Thread Prakhar Jain
I guess the Soln given is O(n) Much better can be achieved through binary serach O(nlogn) int binsearch(int a[],int start,int end,int key) { int mid=(start+end)/2; if(start==end a[mid]!=key) return -1; if(a[mid]key) end=mid; else if(a[mid]key) start=mid; else return mid; } int