Re: [algogeeks] fastest sequential access
singly linked list On Wed, Nov 21, 2012 at 8:21 PM, shady wrote: > which data structure among the follow has fastest sequential access ? > i) vector > ii) Singly linked list > iii) Doubly linked list > > it won't be doubly linked list as it involves more pointer manipulations > than singly linked list... > > -- > > > --
Re: [algogeeks] Array Problem
Hi Sorry for that as i misinterpreted the question. for the difference to be minimum, i think(not completely sure) we can first sort the array and then we can start putting the elements at even index in the last part of the array and the odd ones in the starting in the new array you can do this in the same array itself i guess but you have to do some kind of shifting. by doing this for all the elements and dividing them into two groups. I hope this helps. Vishal On Fri, Nov 16, 2012 at 9:46 AM, bharat b wrote: > @ vishal : how can u divide an array into 2 groups whose difference is > maximum in O(1). why max? > > solution : http://www.youtube.com/watch?v=GdnpQY2j064 > > > > > On Fri, Nov 16, 2012 at 9:22 AM, vishal chaudhary < > vishal.cs.b...@gmail.com> wrote: > >> Hi >> you can first sort the array which can be done in O(nlogn) complexity if >> the number of items in the array is n. >> Then using the indexing of arrays you can divide the array into two >> groups whose difference is going to be maximum and this can be done in O(1) >> complexity. >> So the complete algorithm is going to take O(nlogn) complexity. >> Kindly share an alternative algorithm if you find one with lower >> complexity. >> >> Vishal >> >> >> On Wed, Nov 7, 2012 at 7:43 PM, Arun Kindra >> wrote: >> >>> Given an unsorted array, how to divide them into two equal arrays whose >>> difference of sum is minimum. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from 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] Array Problem
Hi you can first sort the array which can be done in O(nlogn) complexity if the number of items in the array is n. Then using the indexing of arrays you can divide the array into two groups whose difference is going to be maximum and this can be done in O(1) complexity. So the complete algorithm is going to take O(nlogn) complexity. Kindly share an alternative algorithm if you find one with lower complexity. Vishal On Wed, Nov 7, 2012 at 7:43 PM, Arun Kindra wrote: > Given an unsorted array, how to divide them into two equal arrays whose > difference of sum is minimum. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from 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] increment operator...
Hi anil first of all when the program starts k = 5 then compiler enters if region then k is incremented before it is compared with 5 ie k = 6 then condition is checked ie ++k < 5 and it comes out to be false then as it was end operation compiler does not evaluate the second statement ie k++/5 then it goes for or and increments the k variable and then k = 7 then it finds that condition k<=8 to be true. now one of the condition in the or is true and it then prints the value of k as 7 hope this helps u. Vishal Chaudhary 2012/11/6 Anil Sharma > main() > { > int k = 5; > if (++k < 5 && k++/5 || ++k <= 8); > printf("%d ", k); > } > > the output shud be 8 but it comes out to be 7.why??? > as increment operator has higher precedence among them so increment shud > be done throughout at first and after then other operators shud be > evaluated.sooutput shud be 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. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.
hi all, yes you can do it that way, but the thing is why are you increasing the complexity of the problem by again checking the inorder traversal output to be checked for increasing order. just traverse through the ones recursively(as we do it in the inoder traversal) through all the nodes and check whether the left child is less than the root and root is smaller than the right node. Warm Regards Vishal Chaudhary BE(Hons) Computer Science and Engineering BITS Pilani On Tue, Nov 6, 2012 at 12:34 AM, shady 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. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.