Intro:
Arrays are one of the more simpler data structures out there, meaning they are fundamental to your learning in Computer Science. I'm aiming to simply explain them, provide value and then implement them so that you have an example in code. LETS GO!!!!
Theory:
An array is a 'finite, ordered set of elements'.
They're denoted by [].
This means that the length cannot change, it's predefined.
'Ordered' refers to the fact that each element is indexed, starting from 0.
Reference items like this: arrayName[0].
The datatype within the array has to be the same for e.g. ["robin", "blackbird"] (all strings).
1D arrays can be visualised as a list of items, simply one after another (shown above).
2D arrays can be visualised as a table.
3D arrays can be visualised like a box (threeDArray[x,y,z])
Python Implementation:
It should be noted that Python doesn't actually have a built in Array feature although this can be implemented with NumPy. For the purpose of this post and to keep things simple, we will just be using Python lists to represent arrays here.
Here's my implementation:
And here's some of the inbuild Python methods you can use, more info here:
Java Implementation:
There are 2 ways to implement Arrays. Ones as 'Arrays' and one as an 'Array List'. Array List allows changes to the length, making it more flexible. See below for both:
Array Approach:
ArrayList Approach:
Final Things:
As always, thank you for making it this far, please leave comments, they help me so much. Be sure to like and share also, lets try and get 100 views within a week, like we have done previously. Follow CompAndCode on all platforms! Thank You Nibble Byte!!! Hashtags: #computerscience #coding #programming #technology #python #programmer #computer #tech #developer #coder #java #javascript #code #codinglife #webdeveloper #softwareengineer #engineering #machinelearning #softwaredeveloper #html #programmers #software #artificialintelligence #computerengineering #linux #datascience #cybersecurity #programmingmemes #hacking #bhfyp #informationtechnology #programminglife #hacker #css #pythonprogramming #php #webdesign #ai #science #programmerlife #codingmemes #deeplearning #developers #programmerhumor #coderlife #codingisfun #computers #kalilinux #developerlife #development #ethicalhacking #softwareengineering #computerprogramming #windows #coders #codingbootcamp #security #geek #daysofcode #programmingisfun #compandcode
computerscience
code
coder
coding
codinglife
compandcode
computer
developer
html
java
javascript
machinelearning
programmer
programming
python
softwaredeveloper
softwareengineer
tech
technology
webdeveloper
Comments