Re: [algogeeks] Re: Direct - i ques
check the link given by DK for queue and see my post in this thread for stack for doing in O(1)..you guys are discussing the things which are already discussed !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Mon, Aug 1, 2011 at 11:20 AM, Aman (neshu) Agarwal neshuagarwal1...@gmail.com wrote: Think in terms of vector(C++, STL) :P On Mon, Aug 1, 2011 at 11:01 AM, ankit sablok ankit4...@gmail.com wrote: finding min will not take O(1) time in a stack i guess On Mon, Aug 1, 2011 at 10:32 AM, kartik sachan kartik.sac...@gmail.comwrote: I think its stack where deletion insertion and finding min (as we will cal min at the time of insertion only by taking min val ) will take O(1) time correct me if i am worng...! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Aman Agarwal Success is not final, Failure is not fatal: It is the courage to continue that counts! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
@ankit i am saying at the time of insertion of first element to last we have to maintain a min element which store the min number -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
its a *doubly* linked list ... you can easily do the job ... On Sun, Jul 31, 2011 at 2:23 PM, siva viknesh sivavikne...@gmail.comwrote: using LL u cant delete in O(1) ... u have to traverse from head On Jul 31, 1:47 pm, Shubham Maheshwari shubham@gmail.com wrote: use a doubly linked list ... with a field node *min. weneva you insert an element ... check for the value of min at the head ... if the new inserted node has less value ... then set the min field to point to itself else copy the min field of te previous head. insertion and deletion is easy ... and I hope i dont need to expalin that too ... On Sun, Jul 31, 2011 at 12:27 PM, siva viknesh sivavikne...@gmail.com wrote: Create a data structure where inserting, deleting and finding the minimum element all have 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
@shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
you mean circular linked list ...!!! in case of stack ... we cn do it via SSL ... for a queue implementation ... we will ned circular, or doubly for deletion in O(1). On Sun, Jul 31, 2011 at 2:38 PM, naveen ms naveenms...@gmail.com wrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.com wrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
hw cn u ensure that the elements are inserted in sorted order ... wat if the elements are coming randmly ... On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote: Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.com wrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
@shubham maheshawari deletion can't be performed in O(1). after extracting the min element, we need to find the next minimum element, and worst case will take O(n) time. On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari shubham@gmail.comwrote: hw cn u ensure that the elements are inserted in sorted order ... wat if the elements are coming randmly ... On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote: Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.com wrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
the operation is nt extract min ... its *find* min ... On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: @shubham maheshawari deletion can't be performed in O(1). after extracting the min element, we need to find the next minimum element, and worst case will take O(n) time. On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari shubham@gmail.com wrote: hw cn u ensure that the elements are inserted in sorted order ... wat if the elements are coming randmly ... On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote: Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
Qn is : Create a data structure where inserting, deleting and finding the minimum element all have O(1) time. so after deleting the minimum element, where will you point min pointer? Sorry if i m wrong On Sun, Jul 31, 2011 at 3:11 PM, Shubham Maheshwari shubham@gmail.comwrote: the operation is nt extract min ... its *find* min ... On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: @shubham maheshawari deletion can't be performed in O(1). after extracting the min element, we need to find the next minimum element, and worst case will take O(n) time. On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari shubham@gmail.com wrote: hw cn u ensure that the elements are inserted in sorted order ... wat if the elements are coming randmly ... On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote: Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
i am givin solution for implementing a queue or a stack ... in which ...inserting, delelting and finding min element is of O(1). hope this is clear now ... On Sun, Jul 31, 2011 at 3:19 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: Qn is : Create a data structure where inserting, deleting and finding the minimum element all have O(1) time. so after deleting the minimum element, where will you point min pointer? Sorry if i m wrong On Sun, Jul 31, 2011 at 3:11 PM, Shubham Maheshwari shubham@gmail.com wrote: the operation is nt extract min ... its *find* min ... On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: @shubham maheshawari deletion can't be performed in O(1). after extracting the min element, we need to find the next minimum element, and worst case will take O(n) time. On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari shubham@gmail.com wrote: hw cn u ensure that the elements are inserted in sorted order ... wat if the elements are coming randmly ... On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.comwrote: Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
here is what i think should be done to do thees operations in O(1)it is quite popular interview question.. i am using two stacks one stack arr[] in which elements in the elements will be pushed as they are normally done in a stack maintain another stack min[]whenever you insert an element in original stack,insert the index of min element up to that point. so at any point you want to take the min element ,go to the min stack,get the index,value and fetch the element. one example would be -- arr[] min [] 45 2 78 2 38 2 67 0 50 0 hope it is clear now... !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at 3:30 PM, Shubham Maheshwari shubham@gmail.comwrote: i am givin solution for implementing a queue or a stack ... in which ...inserting, delelting and finding min element is of O(1). hope this is clear now ... On Sun, Jul 31, 2011 at 3:19 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: Qn is : Create a data structure where inserting, deleting and finding the minimum element all have O(1) time. so after deleting the minimum element, where will you point min pointer? Sorry if i m wrong On Sun, Jul 31, 2011 at 3:11 PM, Shubham Maheshwari shubham@gmail.com wrote: the operation is nt extract min ... its *find* min ... On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: @shubham maheshawari deletion can't be performed in O(1). after extracting the min element, we need to find the next minimum element, and worst case will take O(n) time. On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari shubham@gmail.com wrote: hw cn u ensure that the elements are inserted in sorted order ... wat if the elements are coming randmly ... On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.comwrote: Use a circular linked list with elements being inserted in sorted order. Inserting minimum element : struct node *p; p is a pointer to last node in the circular singly linked list. newmin-next=p-next; p-next=newmin; Deleting minimum element: struct node *temp; temp=p-next; p-next=p-next-next; free(temp); Retrieving minimum element : return (p-next-ele); *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Abhishek Gupta MCA NIT Calicut Kerela -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
Re: [algogeeks] Re: Direct - i ques
Guys the real question is : Design a data structure which support following operation 1. insertion of an arbitrary element 2. removing the oldest element 3. Accessing min element -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering 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: Direct - i ques
O(1) is possible in normal LL in below case: i.If u have head then insertion , deletion and accesss to first element at front . ii.if u have tail then insertion and access to element at last . if anything missing add anout normal LL On Sun, Jul 31, 2011 at 9:47 PM, siva viknesh sivavikne...@gmail.comwrote: I think the exact question resembles as what ravinder kumar saidAnd all these operations in O(1) time...ideas plz On Jul 31, 5:21 pm, Ravinder Kumar ravinde...@gmail.com wrote: Guys the real question is : Design a data structure which support following operation 1. insertion of an arbitrary element 2. removing the oldest element 3. Accessing min element -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering 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. -- Pandharinath Gorde +91-9620557641 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
i think you can just enter elements in a sorted order ( ie applying insertion sort as the elements are added ) like we do in Bucket sort .. maintaining sorted buckets for a hash value .. and maintaining the min element at the head always we can do deletion of min and finding min in O(1) time because it is always the head. On Sun, Jul 31, 2011 at 10:21 AM, pandharinath gorde pandharinath.go...@gmail.com wrote: O(1) is possible in normal LL in below case: i.If u have head then insertion , deletion and accesss to first element at front . ii.if u have tail then insertion and access to element at last . if anything missing add anout normal LL On Sun, Jul 31, 2011 at 9:47 PM, siva viknesh sivavikne...@gmail.comwrote: I think the exact question resembles as what ravinder kumar saidAnd all these operations in O(1) time...ideas plz On Jul 31, 5:21 pm, Ravinder Kumar ravinde...@gmail.com wrote: Guys the real question is : Design a data structure which support following operation 1. insertion of an arbitrary element 2. removing the oldest element 3. Accessing min element -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering 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. -- Pandharinath Gorde +91-9620557641 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- The more you sweat in the field, the less you bleed in war. Ankit Minglani NITK Surathkal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
This question has already been discussed in depth previously: There are 2 ways to do this: 1. Using 4 stacks (actually 2 min stacks) 2. Using a queue and a deque A highly detailed, easy to understand discussion of the problem has already taken place in the group previously: The complete discussion thread: https://groups.google.com/d/topic/algogeeks/NxFXQjSN7bo/discussion My Solution for the problem (with additional bonus results) as a method that hasn't been posted anywhere else on the web: https://groups.google.com/d/msg/algogeeks/NxFXQjSN7bo/iHm62yEZOgcJ -- DK http://gplus.to/divyekapoor http://www.divye.in http://twitter.com/divyekapoor -- 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/-/MD71295a09EJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
I think its stack where deletion insertion and finding min (as we will cal min at the time of insertion only by taking min val ) will take O(1) time correct me if i am worng...! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
finding min will not take O(1) time in a stack i guess On Mon, Aug 1, 2011 at 10:32 AM, kartik sachan kartik.sac...@gmail.comwrote: I think its stack where deletion insertion and finding min (as we will cal min at the time of insertion only by taking min val ) will take O(1) time correct me if i am worng...! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Direct - i ques
Think in terms of vector(C++, STL) :P On Mon, Aug 1, 2011 at 11:01 AM, ankit sablok ankit4...@gmail.com wrote: finding min will not take O(1) time in a stack i guess On Mon, Aug 1, 2011 at 10:32 AM, kartik sachan kartik.sac...@gmail.comwrote: I think its stack where deletion insertion and finding min (as we will cal min at the time of insertion only by taking min val ) will take O(1) time correct me if i am worng...! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Aman Agarwal Success is not final, Failure is not fatal: It is the courage to continue that counts! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: direct i ..ques
(C(n+1,2))* (C(n+1,2)) choosing any two rows from n+1 rows, and any two columns from n+1 columns will yield a rectangle . So solution is the no of possible combinations. On Wed, Jul 27, 2011 at 11:23 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote: It will be (1+2+3+,,,+n)^2.u can verify it for a chess board hich will have 1296 rectangles for n=8 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Yka7s3mbdwAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: direct i ..ques
C(n+1,2)^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.