Please enable JavaScript.
Coggle requires JavaScript to display documents.
Data Structure (Chapter 2) - Coggle Diagram
Data Structure (Chapter 2)
Data
Unprocessed facts
like : text , symbol, image,sounds, numbers..etc
Data Structure
Organizing a collection of data
like : arrays, lists . hash table,trees,linked lists,queues, stacks..etc
Why?
to write efficient programs
less cost in term of memory(space) and time
To write an efficient program,
good algorithm
good data structure
Why care about speed and space ?
Because data also has grown rapidly, they need to be stored, processed
and retrieved efficiently
Arrays
Group of variables or elements of the same type
Arrays are object--> create with new keyword
Arrays are objects so they are reference types
Memory allocation of an array is contiguous
The array size is fixed/constant
The array size determines the number of elements in the array.
An array can be of any primitive or object type
Array elements are auto initialized
null for references//- 0 for the numeric primitive-type //, false for boolean
Arrays can be:
Local variables
Parameter
Class attribute
return value
Two-dimensional Arrays
data arranged in rows and
columns.
Disadvantages of arrays
limitations on the maximum
size of the array
Poor Performance
Shifting is required when removing an element from unsorted array
Shifting is required when inserting and removing in a sorted array
Fixed size
needed memory must be contiguous,
not scattered