Скачать презентацию Applied Algorithms Lecture 5 Sorting CS 410 Applied Скачать презентацию Applied Algorithms Lecture 5 Sorting CS 410 Applied

460ab57f422bef8f929e81491ede0b66.ppt

  • Количество слайдов: 10

Applied Algorithms Lecture #5 Sorting CS 410 Applied Algorithms Applied Algorithms Lecture #5 Sorting CS 410 Applied Algorithms

Homework Grading Notes Again • You must turn in your homework in class each Homework Grading Notes Again • You must turn in your homework in class each Friday. – Give me a paper copy in class. Email is not convenient for me. • You must turn in the report from the judge. – Homework without a Judge report can get a maximum of 85%. – Always turn in a page or two of output. Try and make the input for the output you turn in be non-standard. Test the gotchas! • Include some sort of high level description of the strategy your program uses to solve the problem. CS 410 Applied Algorithms

Quiz • We have a 10 minute quiz today on the reading – Chapter Quiz • We have a 10 minute quiz today on the reading – Chapter 4. • We will continue to have quizzes until the class gets an average score high enough to convince me that people are doing the reading. CS 410 Applied Algorithms

Paradigms Character Decoding char *rank. Choices = Paradigms Character Decoding char *rank. Choices = "--23456789 TJQKA"; char *suit. Choices = "-CDHS"; void trans(Rank rk[6], Suit st[6], int i, char r, char s) { int j; for (j=2; j<=14; j++) if (rank. Choices[j]==r) rk[i] = j; for (j=1; j<=4 ; j++) if (suit. Choices[j]==s) st[i] = j; } CS 410 Applied Algorithms

Comparison typedef #define int Ordering; LT 0 GT 1 EQ 2 Ordering comp(int i, Comparison typedef #define int Ordering; LT 0 GT 1 EQ 2 Ordering comp(int i, int j) // Compare two ints { if (i==j) return EQ; if (ij) return GT; } CS 410 Applied Algorithms

Lexiographic Ordering lex. Graph(int x[], int y[], int low, int high) { int i; Lexiographic Ordering lex. Graph(int x[], int y[], int low, int high) { int i; // Lexigraphic ordering of x from right-to -left for (i=high; i>=low; i--) { if (x[i] > y[i]) return GT; if (x[i] < y[i]) return LT; } return EQ; } CS 410 Applied Algorithms

Data encodes Control enum hand. Tag {High. Card, Pair, Two. Pair, Three. Ofa. Kind, Data encodes Control enum hand. Tag {High. Card, Pair, Two. Pair, Three. Ofa. Kind, Straight, Flush, Full. House, Four. Ofa. Kind, Straight. Flush}; struct Hand { // The union enum hand. Tag tag; // union { Rank high. Card[6]; // Rank pair[5]; // Rank two. Pair[4]; // Rank three. Ofa. Kind; // Rank straight; // Rank flush[6]; // Rank full. House; // Rank four. Ofa. Kind; // Rank straight. Flush; // } data; } xx; typedef struct Hand HAND; CS 410 Applied Algorithms is the info needed to break ties its either One card or a Set of cards [lowest. . highest] [lowest. . highest, Pair] [lone card, lower pair, higher pair] Rank of triple highest card in straight [lowest. . highest] Rank of 3 -of-a-kind in full house Rank of quad highest card in straight

CS 410 Applied Algorithms CS 410 Applied Algorithms

In Class Problems • Vito’s Family 4. 6. 1 – Page 88 of the In Class Problems • Vito’s Family 4. 6. 1 – Page 88 of the text – We will write this together as a class • Bridge 4. 6. 3 – Page 91 of the text – Keeping in mind today’s lecture. – Pairs of two CS 410 Applied Algorithms

Today’s Assignments Read for next time Chapter 5 of the text. pp 102 -128 Today’s Assignments Read for next time Chapter 5 of the text. pp 102 -128 Be prepared to answer questions in class next Friday from the reading. Programming assignment • 4. 6. 5 Shoemaker's Problem • - Page 94 • Write a solution Submit your solution (until you get it right) Hand in both your program, and the judge output. Those who volunteer to discuss their program get class participation points. Email me solutions before noon on Friday, May 6. CS 410 Applied Algorithms