Adventures in Snap Programming: Learn to design exciting and challenging programs (Learning computer programming and CS principles Book 10) by Joshi Abhay
Author:Joshi, Abhay [Joshi, Abhay]
Language: eng
Format: epub
Publisher: SPARK Institute and Publications
Published: 2020-10-26T00:00:00+00:00
Feature idea #4: Delay and highlight
Since the main purpose of this program is to learn about the Bubble Sort algorithm, it would be nice to able to watch the algorithm in slow motion.
Step 1 : Add the feature to control the speed of every swap.
Design:
This can be achieved by having a slider variable called "delay" and using "glide" instead of "go to x y" when we move the bars.
The problem is this will also slow down the "shuffling" of bars, which we are not really interested in watching in slow motion. The easy fix for this is to set the delay to 0 temporarily during shuffling.
Step 2 : Highlight the pair of bars which has been selected to be swapped.
Design:
This can be achieved by having the selected bars change their color before the swap and resetting it after.
Step 3 : Vary the thickness of bars based on the total count. The bars should be thinner if the count is large and thicker if the count is small.
Design:
Since there is no way in Snap to resize only the thickness of bars, we will use 3 separate costumes to accommodate different ranges. One is for 5 to 20, second is 20 to 50, and third is 50 to 100. The choice of the appropriate costume would be made during setup.
Save as Program Version âFinalâ
Congratulations! You have completed all the main features of the program. Compare your program with my program at the link below.
Solution: BubbleSort-final.xml
Also available at the Berkeley Snap website: Bubble sort
( https://snap.berkeley.edu/snapsource/snap.html#present:Username=abjoshi&ProjectName=BubbleSort-fina l )
How to run the program:
Click the âGreen flagâ: A sorted (in ascending order) array of numbers will be created. The bars displayed on the screen will be sorted accordingly. Set the "delay" slider appropriately.
Click the âShuffleâ button: the list will be shuffled. The bars displayed on the screen will be shuffled accordingly.
Click the âSortâ button: Start sorting the list. For each comparison the bars will be colored, for each swap the bars will be swapped.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9911)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9794)
The Mikado Method by Ola Ellnestam Daniel Brolund(9775)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8292)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7775)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7758)
Grails in Action by Glen Smith Peter Ledbrook(7693)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Windows APT Warfare by Sheng-Hao Ma(6779)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6505)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6373)
Kotlin in Action by Dmitry Jemerov(5061)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4314)
Functional Programming in JavaScript by Mantyla Dan(4037)
Solidity Programming Essentials by Ritesh Modi(3975)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3758)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3702)
The Ultimate iOS Interview Playbook by Avi Tsadok(3676)
