CS ListsAndArrays

Embed Size (px)

Citation preview

  • 8/18/2019 CS ListsAndArrays

    1/1

    Stella Connaughton

    Explanations

    Lists and arrays are ways of programming many objects in less code. It is more

    ecient than programming every object individually as it ta!es less time and

    space. "or example a program showing a school of #sh would be more ecient as alist or array rather than individually program every #sh to move. $hey should be

    used when needing to program many objects in a similar fashion.

    In %lice to create lists and arrays you go to &create new variable' and chec!

    ma!e a &list' or &array'. (ou then are able to designate objects as item) item* and

    so on. (ou are able to use two control statements with lists and arrays. "irst +"or %ll

     $ogether, you can program every single object to perform an action at the same

    time. "or example a swarm of bees moving forward would need a +"or %ll $ogether,

    statement because they would all move the same way. $he other statement is +"or

    %ll in -rder,. -ne would use a +"or %ll in -rder, statement when they want each

    object to do a certain method one at a time. "or example if somebody wanted toma!e a program of cars moving one by one on a street they would use a +"or %ll in

    -rder, statement.

    Lists and arrays both serve the same purpose. $hey are both data structures.

     $heir primary goal is to allow the user to program multiple objects in less code.

    %rrays and lists index objects from )/. 0owever lists are more expendable. 1hile

    arrays have #xed 2 of items when you #rst initiali3e an array you can add or

    remove objects in an array. %dditionally elements in an array are ordered but

    elements in a list are not. 0owever due to this reason arrays are often more

    ecient as they are not as complex and will not ta!e up as much memory as a list

    would. $here are also 4 types of arrays5 visual and nonvisual.