ScratchData LogoScratchData
Back to Hobson-TV's profile

The RAM Model

HOHobson-TV•Created September 27, 2022
The RAM Model
416
337
8435 views
View on Scratch

Description

Instructions: Watch the program run, and use the view variable to change tabs to either look at memory, the commands for the program, or the output. The RAM model is a way to represent computer programs/algorithms. Basically, you have 'memory' and 'variables': variables are just variables, and memory is just a list you can change values of. A RAM program is just a list of basic commands, of which there are 5 types: Assignment: var1 = [number] Operations: var1 = var2 + var3 (addition, subtraction, multiplication, division) Write: M[var1] = var2 Read: var1 = M[var2] Goto: if (var1 == 0) go to line [number] ...and that's it. with these 5 commands you can (in theory) write anything you could make in Python, or in Scratch. The current program sorts a list of random values from 0 to to 255. Notice that when it finishes, it puts numbers in ascending order! I couldn't be bothered to write a UI to write your own code, but you can write it using scratch blocks. Model your program after the code in the "*INSERTION SORT" block. The RAM model code for Insertion Sort is borrowed from a class I'm taking. This project was inspired by the class. Insertion Sort has time complexity O(n^2), and in this case it sorts 512 integers in 300,000 steps. Faster sorting algorithms run in time O(nlogn), which is asymptotically faster. I estimate one could solve this in under 50,000 steps. However, I do not have the patience to write one of these algorithms in assembly code...

Project Details

Project ID737315263
CreatedSeptember 27, 2022
Last ModifiedDecember 13, 2022
SharedDecember 13, 2022
Visibilityvisible
CommentsAllowed