Applied Algorithms - PowerPoint PPT Presentation

About This Presentation
Title:

Applied Algorithms

Description:

You must turn in your homework in class each Friday. Give me a paper ... Rank fullHouse; // Rank of 3-of-a-kind in full house. Rank fourOfaKind; // Rank of quad ... – PowerPoint PPT presentation

Number of Views:72
Avg rating:3.0/5.0
Slides: 11
Provided by: she46
Learn more at: http://web.cecs.pdx.edu
Category:

less

Transcript and Presenter's Notes

Title: Applied Algorithms


1
Applied Algorithms
  • Lecture 5
  • Sorting

2
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.

3
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.

4
Paradigms
  • Character Decoding
  • char rankChoices "--23456789TJQKA"
  • char suitChoices "-CDHS"
  • void trans(Rank rk6,Suit st6, int i, char r,
    char s)
  • int j
  • for (j2 jlt14 j) if (rankChoicesjr)
    rki j
  • for (j1 jlt4 j) if (suitChoicesjs)
    sti j

5
Comparison
  • typedef int Ordering
  • define LT 0
  • define GT 1
  • define EQ 2
  • Ordering comp(int i, int j) // Compare two ints
  • if (ij) return EQ
  • if (iltj) return LT
  • if (igtj) return GT

6
Lexiographic Ordering
  • Ordering lexGraph(int x, int y,
  • int low, int high)
  • int i // Lexigraphic ordering of x from
    right-to-left
  • for (ihigh igtlow i--)
  • if (xi gt yi) return GT
  • if (xi lt yi) return LT
  • return EQ

7
Data encodes Control
  • enum handTag HighCard, Pair, TwoPair,
    ThreeOfaKind, Straight,
  • Flush, FullHouse, FourOfaKind,
    StraightFlush
  • struct Hand // The union is the info
    needed to break ties
  • enum handTag tag // its either One
    card or a Set of cards
  • union Rank highCard6 // lowest ..
    highest
  • Rank pair5 // lowest ..
    highest,Pair
  • Rank twoPair4 // lone card,lower
    pair,higher pair
  • Rank threeOfaKind // Rank of triple
  • Rank straight // highest card in
    straight
  • Rank flush6 // lowest ..
    highest
  • Rank fullHouse // Rank of
    3-of-a-kind in full house
  • Rank fourOfaKind // Rank of quad
  • Rank straightFlush // highest card in
    straight
  • data xx
  • typedef struct Hand HAND

8
(No Transcript)
9
In Class Problems
  • Vitos 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 todays lecture.
  • Pairs of two

10
Todays 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.
Write a Comment
User Comments (0)
About PowerShow.com