This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-03-23 23:12:24

Zoob04
Scratcher
Registered: 2009-03-23
Posts: 2

Sorting lists bubble and selection sort

Hi.. So I jus started using scratch and I'm still not so familiar with it. I wonder if anyone can give me any hints on how to do this project
1) create a list and variables LENGTH,MINVAL,MAXVAL.
and assign a positive integer value to the variable lenght and intger values to maxval and minval. The variable lenght is taken as the total items in the list. Assign a value to each item in the list so it is a random number between minval and maxval

2)
Make a procedure called bubble that sorts items in the list in an increasing order using the bubble sort algorithm

3) make a procedure called selection that sorts items in the list using the selection sort algorithm in increasing order

This is what I have to do and I'm totally lost.. So any help would be appreciated
Thanks

Offline

 

#2 2009-03-24 04:35:53

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Sorting lists bubble and selection sort

That sounds a lot like a homework project...

Rather than just give you the answer (which wouldn't help you learn very much), can you tell us what part you are stuck on and maybe we can help you with that?  For example, have you downloaded the Scratch program so you can progam in it?  Do you know how to make variables and lists?  Where are you in the process?


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2009-03-24 08:33:11

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Sorting lists bubble and selection sort

Why do teachers allways make things difficult?  big_smile  I have no clue why you would use words like "procedure", "integer value", ...? I'd start translating it to normal  scratch language:

1) create a list and variables LENGTH, MINVAL,MAXVAL.minval and maxval are numbers. Assign a value to each item in the list so it is a random number between minval and maxval

2) Make a script started with a broadcast "bubble" that sorts items in the list in an increasing order using the bubble sort algorithm

3) Make a script started with a broadcast "bubble"  that sorts items in the list using the selection sort algorithm in increasing order

I'm not telling you the solution (have my own homework you know  tongue  ) but I have some tips. Random numbers can be done with the "pick random () to ()". Thats where you'll need your minval and maxval probably, and also the length variable!

The two sort algorithms, two options:
- You already know them and just start programming
or...
- www.google.com or just the scratch website. Tip: list sorting has been done already, nice search feature at the top of the page (go to home then search, not a forum search)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#4 2009-03-24 13:02:12

Zoob04
Scratcher
Registered: 2009-03-23
Posts: 2

Re: Sorting lists bubble and selection sort

Hey I have downloaded scratch an I managed to make a list of random value with the minval and maxval set to a certain value... The first part

I'm basically stuck on how to make the program for sorting
Like for bubble I know wat the bubble sort algorithm is and how values continue to being swapped from top to bottom till all value in increasing order

I'm jus not sure how to make it on scratch. Like how to set swap index 1 with index two if value is lower and so on and then repeat.

Same wit slection not sure how to set the swapping part
Thanks

Offline

 

#5 2009-03-24 13:13:58

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Sorting lists bubble and selection sort

You know, the website is full of open source projects for many things. If you wanted to see a project for bubble sort you could just enter bubble sort into the website's search bar.

http://scratch.mit.edu/projects/Jens/257519

That is the first result for "bubble sort"


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#6 2009-03-24 14:32:00

radacheck
Scratcher
Registered: 2007-11-27
Posts: 2

Re: Sorting lists bubble and selection sort

Is it possible to write a checkbook balancing program or a 12 month calendar program in Scratch?
In both of these things data must be saved and reloaded , can this be dine?

Offline

 

#7 2009-03-24 14:46:17

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: Sorting lists bubble and selection sort

i think so, but not online. Its gonna be a lot of work however. Your gonna need to have non reseted variables, and save constantly. Also scratch has no way to get the date.

Offline

 

#8 2009-03-24 15:21:05

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Sorting lists bubble and selection sort

yambanshee wrote:

i think so, but not online. Its gonna be a lot of work however. Your gonna need to have non reseted variables, and save constantly. Also scratch has no way to get the date.

I did write a Python/Scratch pair of programs that used the Scratch sockets to get the system time and date from the Python piece...so Scratch does have a way to get the date...it's just really awkward  smile


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#9 2010-03-04 12:23:33

cmon
Scratcher
Registered: 2010-03-04
Posts: 1

Re: Sorting lists bubble and selection sort

what are 'selections' ,'iteration' and 'sequences'?
I am doing this for homework and I am not sure what they are.
Please help me!

Offline

 

#10 2010-03-04 13:21:25

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Sorting lists bubble and selection sort

cmon wrote:

what are 'selections' ,'iteration' and 'sequences'?
I am doing this for homework and I am not sure what they are.
Please help me!

You might get a better response if you start your own topic by using the "Post new topic" link at the top right section of the forum main page.  Probably the Miscellaneous forum would be your best bet.  I can't really figure out what you're asking for without some kind of context.  What subject are you discussing?


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer