CMSC 131A- Final Exam Guide - Comprehensive Notes for the exam ( 173 pages long!)

140 views173 pages

Document Summary

There are a wide variety of data structures that we can use or create to attempt to hold data in useful, organized, efficient ways. Similar to an arraylist, an array is a linear, contiguous, homogenous structure that can hold an arbitrary number of elements but is available in all languages. Elements in an array of size n are indexed (some languages do 1n, many like java use 0n-1) and that is the only way we can access items inside. The data structure has a first and last position. In an array with more than 1 element, any position other than the first has a previous position and any position other than the last has a next position. In java, an array is an object and we will have a variable serve as a reference to that object. We will indicate the type of elements that will be stored when we declare it. datatype[] arrayname;