CS 18000 Chapter Notes - Chapter 18: Dynamic Array, Linked List, The Queue

37 views4 pages

Document Summary

Data structure: a way to organize, store, and retrieve information in a program. Dynamic data structure: a data structure whose memory can grow or shrink as necessary to store the information being maintained. Like an array, but grows as elements are added. How we can write our own version using what we"ve got: fixed-sized arrays, abstraction through class definition, accessor and mutator methods. Keep track of: actual number of elements currently stored vs, capacity of the underlying array. Use accessor and mutator methods to control access, enforcing the abtraction. If the actual number of elements becomes larger than current capacity: allocate a new underlying array, copy old array elements into it, free old array (and elements it references) Allocate new instances: arraylist a = new arraylist (); Add elements to the end of the array: a. add ( hello ); Replace (set) a specific element in the array: a. set (0, world );

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents