Chapter 4 Understanding Arrays
Chapter 4 Understanding Arrays
Computer Science
Chapter 4 - Understanding Arrays & Collections
Notes
1. What is the starting index of an array?
Answer: 0
2. What are collections?
• A collection is a container that groups multiple items into a single object.
• Collections are used to store data.
• We can also retrieve and manipulate data that is stored in the Collections.
• Examples: a deck of cards, a phone book directory, a mail folder
3. What are the different types of collections?
The Different types of collections are-
Array, List, Sets, Maps, Dictionary
4. How can we iterate over collections?
• The iterators are used to sequentially access collections.
• An iteration takes elements from a collection one after another.
• We always need to traverse through the elements of these collections to fetch the data or make any
modifications to that data.
5. What are the different types of modifications that we can perform on collections?
The modifications that we can do on collections.
• Adding Elements During Iteration
• Removing Elements During Iteration
6. What is an Array Index?
• Array index can be defined as the location of an item in an array.
• The variables that are present in array are always ordered sequentially with index starting from 0.
• The indexes continue through the natural numbers i.e 1,2,3,4…
7. Do collections allow backward traversing of data? Support your answer with a proper
explanation.
• Yes, collections do allow backward traversing of data just like we can iterate a collection from the
front with the index position being 0.
• In reverse traversing, we start from the last element whose index position is -1.
8. Name three real-life collections that work like Arrays.
• Arranging books: Having a pile of books and arranging them in your book rack
• An Array of Chairs: An array of chairs in an auditorium
• An egg tray: An egg tray. Having eggs placed in rows.