忍者ブログ

cheapsaleee

michael kors discount bags into those of size less

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

コメント

ただいまコメントを受けつけておりません。

michael kors discount bags into those of size less

Finding matches in two bags Given a bag of nuts and a bag of bolts, each having a different size within a bag but exactly one match in the other bag, give a fast algorithm to find all matches. Since there is always a match between 2 bags, i said there will be same number of nuts and same number of bolts.Let the number be n. I would first sort components in each bag each component's weight, and it is possible to do that because they all have different size within a bag.Using merge sort, it will have o(N log n)Time complexity. Next, it would be just easy process of matching each component in ichaelorhandagotlet 2 bags from lightest to heaviest. I want to know if this is the right solution, and also if there is any other interesting way to solve this problem. Assuming you have no exact measurements of size, and you can only see if something is too large, too small, or exactly right by trying, this needs the extra step of how you are sorting which is probably by taking a random nut, comparing with each bolt and sorting into smaller, bigger piles, and then taking a bolt and sorting the nuts with that(A modified quicksort.Keep in mind you'll have to deal with the problem of how to choose a nut or bolt to compare to when the piles get smaller as to make sure you're using a reasonable pivot). Since the problem doesn't tell you that the nuts and bolts are labeled with sizes, or that you have some way of measuring the nuts and bolts' sizes, it would be difficult to use a hash table to solve this, or even a regular comparison sort. There is a solution to this problem in o(Nlgn)That works even if you can't compare two nuts or two bolts directly.That is without using a scale, or if the differences in weight are too small to observe. It works by applying a small variation of randomised quicksort as follows: Pick a random bolt b. Compare bolt b with all the nuts, partitioning the nuts michael kors discount bags into those of size less than b and greater than b. Now we must also partition the bolts into two halves as well and we can't compare bolt to bolt.But now we know what is the matching nut n to b.So we compare n to all the bolts, partitioning them into those of size less than n and greater than n. The rest of the problem follows directly from randomised quicksort by applying the same steps to the lessthan and greaterthan partitions of nuts and bolts.

PR

コメント

プロフィール

HN:
No Name Ninja
性別:
非公開

カテゴリー

P R