Sachin veldi APCS-P ModuleSixLessonTwoActivityGuide

docx

School

Trident Technical College *

*We aren’t endorsed by this school

Course

12

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by EarlIce11831

Report
Google Doc Access Directions: Please click on File in the upper left corner. If you are working on a Chromebook or Google Docs, choose the Make a copy option and save a copy of the document to your Google Drive. If not, choose the Download as option and then the Microsoft Word (.docx) option to download an editable copy of the document to your computer. Module Six Lesson Two Activity Guide Navigate to the Ticket Generator App in code.org You can use the indicated supplies(sticky notes) or these digital manipulatives to work your way through the activity. DIRECTIONS : In this activity, you will develop two (or more) algorithms to find the winning ticket among a group of tickets. The winning ticket will be revealed and you must describe how you will search the tickets that were sold to find the winner. Activity 1 (20 points total) In the space below, describe the algorithm you would use to find a winning number in a list of tickets (5 points) : I would first check each ticket to see if it matched the winning number. If the ticket didn’t match, I would cycle to the next ticket until it satisfied the condition. Use the app generate 3 tickets values to test your algorithm for 3 tickets . (15 points) Select 3 tickets from the dropdown. Click Pick Winner Following your algorithm, click on each ticket image. Record how many clicks it took to find the winning number. Repeat 3 times (click new numbers), and record the number of clicks. Record the number of clicks needed to find the winning number: Test 1: 2 Test 2: 3 Test 3: 2 Activity 2 (15 points) Use the app to test your algorithm with 6 tickets .
Select 6 tickets from the dropdown. Click Pick Winner Following your algorithm, click on each ticket image. Record how many clicks it took to find the winning number. Repeat 3 times (click new numbers), and record the number of clicks. Record the number of clicks needed to find the winning number: Test 1: 4 Test 2: 2 Test 3: 6 Predict: (15 points) Think about what would happen if we had ten tickets, enough tickets for the whole class or the whole school? This is the linear search pattern. What would happen if we had 1000 tickets? It would take a long time to find the winning ticket, and the algorithm would be deemed inefficient. What is the most number of clicks it would take? It would take 1000 clicks at the most. What is the pattern here? The most amount of clicks it could take is the amount of tickets printed. Activity 3: (15 points) Create an algorithm to determine if the winning number is in a list of sorted tickets. (the top ticket has the lowest value and the bottom ticket has the highest). Click on this Sorted Ticket App. The search can start at any of the tickets. You can "jump" over tickets. In other words, you don't need to search the tickets in order. You can determine which ticket to click next based on the current ticket you are checking. The goal is to make the determination in the least steps possible, but don't forget your number could be anywhere in the list - what is the worst possible case? What is the greatest number of comparison steps it would take to find any number in your list using your current algorithm? Challenge algorithm: The algorithm would pick a ticket in the list at random. If the item was too small, then the algorithm would only randomly pick greater numbers than that ticket. If the item was too big, then the algorithm would only randomly pick lesser numbers than that ticket. This process would repeat until the winning ticket was matched. In the worst possible case, it would take 1000 tries, however, the actual number will usually be much less. 2
Record the number of clicks needed to find the winning number when testing your sorted ticket algorithm for 6 sorted tickets (15 points) : Test 1: 2 Test 2: 2 Test 3: 3 Watch this short video of how a Binary Search might work and answer the following questions. (20 points) How does your sorted ticket algorithm compare to the binary search algorithm? It is much faster to find winning tickets using the sorted ticket algorithm since the list can effectively be halved and sorted quicker, looking at whether it is greater than or lesser than the winning ticket. If you had two tickets, which algorithm would you use to get a match with the fewest amount of steps? I would use the binary search algorithm, although it wouldn’t matter much since it would always take 2 tries. What if you had five? If I had 5, I would use the sorted algorithm as the list can effectively be halved and sorted quicker; looking at whether it is greater than or lesser than the winning ticket. What about one hundred? If I had 100, I would definitely use the sorted algorithm as the list can effectively be halved and sorted quicker; looking at whether it is greater than or lesser than the winning ticket. Check out this Binary Search Pattern . 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help