Download presentation
Presentation is loading. Please wait.
1
Bingo Example: Design (Fill Card Algorithm)
J. Michael Moore CSCE 121
2
Approach Recall from the analysis
we can get a random value from 1-15 Transform it to an appropriate value row*15 + random value from 1 to 15 We’ll integrate the algorithm we developed for getting distinct random numbers Fill column by column since random numbers 1-15 will be for each column, not for a row.
3
Algorithm row ← 0, col ← 0, maxVal ← 15, numToGet ← 5
Create empty 2D container card For each column (col from 0 to numToGet-1) Load bag with values from 1 to maxVal For each row (row from 0 to numToGet-1) index ← randomvalue that is any valid index for bag card[row][col] ← bag[index] + col*maxVal Remove element at index from bag
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.