top of page

Refresher on Arrays and Stacks

Arrays

 

Think of arrays as a infintely big house. In this house you can have an unlimited amount of rooms. These rooms you can think of as dimensions. Inside these rooms you can have closests and the like. The less dimensions or rooms you have in your house the faster it is to get between them. This is true especially in Small Basic where more than 1 Dimension or more than 100 rooms slows down the array signficantly . When speed is of concern it is recomended that whenever possible to make 1D Arrays.

Here is an example of a 1D Array:

Output:

Here is an example of a 2D Array:

Output:

Do note that 3 Dimensional Arrays are possible but are very slow and are not recommended and hence not covered by this tutorial series.

 

Stacks

 

Stacks are akin to a stack of coins. Placing them on top of a coin tower so to speak. You can only access the top coin of the coin tower. Stacks in essence are First in Last out unlike arrays which can be accessed at any point in the index.

Here is an example:

 

Conclusion

 

In conclusion arrays can be accessed at any point while stacks have constraints to how they can be accessed. Stacks can be used to get data in reverse order of how it was put in. They also act as 1D arrays and may be faster than Small Basic arrays from time to time.

Recomendation

Spend some time tinkering with our code and come up with ways of how you would use Arrays and Stacks. Distinguish between the two if possible.

Featured Posts
Check back soon
Once posts are published, you’ll see them here.
Recent Posts
Search By Tags
No tags yet.
bottom of page