A Beginner's Guide to Starting a Project

  • Context: MHB 
  • Thread starter Thread starter Ilikebugs
  • Start date Start date
  • Tags Tags
    Project
Click For Summary

Discussion Overview

The discussion revolves around starting a project related to a card searching problem, exploring various approaches to determine the number of probes required to find cards arranged in different orders. The scope includes mathematical reasoning and exploratory problem-solving.

Discussion Character

  • Exploratory
  • Mathematical reasoning

Main Points Raised

  • Some participants express uncertainty about how to begin tackling the card problem.
  • One participant suggests that the problem's origin is from a teacher who provides weekly challenges.
  • Several participants propose different mathematical formulations for the number of probes needed, with one suggesting a formula of n(n+3)/2-1 for n cards.
  • Another participant believes that the maximum number of probes for n=10 cards is 64, based on computer verification for values up to 10.
  • Some participants discuss the worst-case scenarios for searching the cards, with varying interpretations of what constitutes the worst case.
  • A participant shares a programming approach to verify the maximum number of probes, including code snippets and explanations of the algorithm used.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the correct formula or the maximum number of probes required, with multiple competing views and interpretations of the problem remaining unresolved.

Contextual Notes

Some participants mention that their understanding of the problem evolves as they discuss it, indicating that assumptions and interpretations may vary. There are also references to specific cases and scenarios that have not been fully resolved or proven.

Ilikebugs
Messages
94
Reaction score
0
I don't know where to startView attachment 6552
 

Attachments

  • potw 7 2.png
    potw 7 2.png
    43.7 KB · Views: 136
Mathematics news on Phys.org
So what do you get for "solving" one of these things? I think whoever helps you should get a cut.

-Dan
 
Hi Ilikebugs. Where do these problems come from?
 
my teacher puts it in a drive every week
 
Ilikebugs said:
my teacher puts it in a drive every week

I think to begin, I would imagine that Randi has the cards arranged in the same order she will seek them...for example suppose she will seek them in the order:

A B C D E F G H I J

and this is the order in which they are arranged. How many cards will she have to look at?

Next, imagine she will seek them in the same order as before, but this time they are arranged in the opposite orderr:

J I H G F E D C B A

How many cards will she have to look at?

Then, keeping the same order of seeking, but using at least two random orderings (not including the two orders previously checked), count how many cards she would have to look at. I recommend getting a deck of playing cards to conduct your trials.

What are your findings?
 
I got 2(2+4+6+8+10)=60
 
I don't have a proof yet, but I'm convinced that the answer for n cards is n(n+3)/2-1. So for n=10, the answer is 64. If I can come up with a proof, I'll post again. The computer verified the formula for values of n up to and including 10. For n=10, the value 64 is realized for initial
ordering of the cards ABCDEFGHIJ and search order BCDEFGHIJA; you can verify by hand that 64 "probes" are needed. Furthermore, the machine found that this is the only situation requiring 64 probes. This must lead to a proof, but I don't see it.

P.S. At first I thought as you did that the answer for n=10 cards is 60, but the machine convinced me otherwise.
 
Last edited:
johng said:
I don't have a proof yet, but I'm convinced that the answer for n cards is n(n+3)/2-1. So for n=10, the answer is 64. If I can come up with a proof, I'll post again. The computer verified the formula for values of n up to and including 10. For n=10, the value 64 is realized for initial
ordering of the cards ABCDEFGHIJ and search order BCDEFGHIJA; you can verify by hand that 64 "probes" are needed. Furthermore, the machine found that this is the only situation requiring 64 probes. This must lead to a proof, but I don't see it.

P.S. At first I thought as you did that the answer for n=10 cards is 60, but the machine convinced me otherwise.

Interesting...I also thought 60 would be the maximum number too. (Thinking)
 
Here's a sketch for why 64 is the correct answer (procrastinating from studying for my exams...). If we think that the worse case scenario is when the cards are placed in position [1,2,3,4,5,6,7,8,9,10], and we search in the order [10,9,8,7,...], then that would yield 60. But, the true worse case scenario is when we search in the order [2,3,4,5,6,7,8,9,1], where the "first" element in the array is shifted $n$ times to the right, where $n$ is the size of the array. So, for $n$ cards, the answer is $n(n+1)/2-1$ + $n$.
 
Last edited:
  • #10
Rido12 said:
Here's a sketch for why 64 is the correct answer (procrastinating from studying for my exams...). If we think that the worse case scenario is when the cards are placed in position [1,2,3,4,5,6,7,8,9,10], and we search in the order [10,9,8,7,...], then that would yield 60. But, the true worse case scenario is when we search in the order [2,3,4,5,6,7,8,9,1], where the "first" element in the array is shifted $n$ times to the right, where $n$ is the size of the array. So, for $n$ cards, the answer is $n(n+1)/2-1$ + $n$.

Yes, now it makes sense to me the think of the "worst case scenario" for $n$ cards (let's call this $W_n$) to be:

$$W_n=\sum_{k=2}^{n}(k)+n=\frac{n(n+1)}{2}-1+n=\frac{n^2+3n-2}{2}$$

This avoids the case where the desired card is in the leftmost position, but all other positions 2-10 are utilized and guarantees two occasions where the desired card is in the rightmost position. Basically, we can have all positions where positions 1-10 are realized, and because of swapping, we can replace the smallest (1) with the largest ($n$) to get the maximum, which you and John got with your orderings. (Yes)

edit: Interestingly, it appears that the best cast scenario $B_n$ is:

$$B_n=\sum_{k=1}^{n}(k)=\frac{n(n+1)}{2}$$

And that occurs when the cards are ordered in the seek order. And after all cards have been swapped during the best case trial, they are now in the order for the worst case if the same seek order is used. :D
 
  • #11
I really didn't understand Mark's proof and have been stewing about the problem. I'm finally satisfied. For those of you who know programming, I include the program I wrote. The proof occurs as comment before method processPerm in class Permutation.

Code:
package permproblem;

public class Permproblem {

   public static void main(String[] args) {
      int n=10;
      Permutation b=new Permutation(n);
      b.generatePerms(n);
      
      System.out.println(b.maxProbes);
   }
   
}

Code:
package permproblem;

/* Given the array a with components 1..n in order and a permutation of 
   1..n perm, search the array a for perm[i], i=1..n.  Count the probes
   necessary for each search.  After each search is concluded with perm[i]
   foune at a[j], if j>0 swap the components a[j] and a[j-1].  The total number
   of probes for all the components perm[i] is counted.  Then the maximum
   number of probes for all permutations is n(n+3)/2-1.  This max occurs
   only for the permutation perm: 1 2 3 .. n-2 0.  Proof?  The program shows
   this is true for n up to 10.
*/
public class Permutation {
   int n;
   int[] perm;
   int[] a;
   boolean[] found;
   int maxProbes = 0;

   Permutation(int n1) {
      n = n1;
      perm = new int[n+1];
      a = new int[n+1];
      found=new boolean[n+1];
      int i;
      for (i = 1; i <= n; i++) {
         perm[i] = i;
      }
   }

/* for i=1 to n, searches for perm[i] in array a, initially for all i, a[i]=i.
   The number of probes (number of times a given component of a is examined)
   is counted.  Originally, if perm[i] is found at component j of a with j!=1,
   a[j] and a[j-1] are swapped.  However, if a[j-1] has already been found,
   this swap is not necessay for the counting of the number of probes.  So
   a boolean array found is maintained with a[k] true iff k has been 
   found.  So the swap is done only when a[j-1] has found[a[j-1]] false.  
   Count the number of swaps executed as moves; there is at most one move for
   each search for perm[i]. Then probes=n(n+1)/2+moves: the number of probes
   for perm[i] is i plus the number of times perm[i] has moved to the "right"
   in array a.  "Clearly" with this revision, there can be at most n-1 moves;
   when the search for perm[n] occurs the condition found[a[j-1]] is true.
   Finally then the maximum number of probes is n(n+1)/2+n-1=n(n+3)/2-1.  This
   maximum is achieved for perm equal to 2 3 4 ... n 1; as to why this is the
   only permutation with n-1 moves, I'm tired of thinking of the problem.
*/   
   void processPerm() {
      int i, m, j, probes = 0, moves = 0;
      for (i = 1; i <= n; i++) {
         a[i] = i;
         found[i] = false;
      }
      for (i = 1; i <= n; i++) {
         m = perm[i];
         found[m] = true;
         j = 1;
         while (j <= n && a[j] != m) {
            j++;
         }
         probes += j;
         if (j > 1 && !found[a[j - 1]]) {
            swap(a, j, j - 1);
            moves++;
         }
      }
      if (probes > maxProbes) {
         maxProbes = probes;
      }
   }

// merely swaps components b[i] and b[j]   
   void swap(int[] b, int i, int j) {
      int temp = b[i];
      b[i] = b[j];
      b[j] = temp;
   }
  
// "standard" recursive generation of all permutations of 1..n;  initial call
// has perm[i]=i for all i   
   void generatePerms(int n) {
      if (n == 1) {
         processPerm();
         return;
      }
      int i;
      for (i = n; i >= 1; i--) {
         if (i != n) {
            swap(perm, i, n);
         }
         generatePerms(n - 1);
         if (i != n) {
            swap(perm, i, n);
         }
      }
   }
 
  • #12
johng said:
I really didn't understand Mark's proof and have been stewing about the problem...

I didn't intend for my post(s) to be taken as any kind of proof, just my musings on the explanations given by others. :D
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
910
  • · Replies 2 ·
Replies
2
Views
1K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
987
  • Sticky
  • · Replies 7 ·
Replies
7
Views
10K
  • · Replies 2 ·
Replies
2
Views
2K