jgs
CSE 205
Object-Oriented Programming and
Data Structures
Lecture 16: Data Structures I
Dr. Javier Gonzalez-Sanchez
[email protected]
javiergs.engineering.asu.edu | javiergs.com
PERALTA 230U
Office Hours: By appointment
Slide 2
Slide 2 text
jgs
Previously on
Programming 101 (and Java fundamentals)
Slide 3
Slide 3 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 3
jgs
Previously
Slide 4
Slide 4 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 4
jgs
Previously
byte
Slide 5
Slide 5 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 5
jgs
Previously
0x01 0x02
0xE6 0xE7
Slide 6
Slide 6 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 6
jgs
Previously
int foobar = 7 // java
00000000 00000000 00000000 00000111
byte
0x73
byte
0x74
byte
0x75
byte
0x76
Slide 7
Slide 7 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 7
jgs
Previously | Variables
int foobar = 7; // java
0x73
7
foobar
4 bytes
aka a variable of type int
Slide 8
Slide 8 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 8
jgs
Previously | Variables with Primitive Types
char x = 'a’;
int y = 7;
float z = 2.5;
a 7 2.5
0x33
x
0x53
y
0x75
z
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 11
jgs
Previously | Objects
MyPoint anObject = new MyPoint(1,3); // java
0x73
anObject
1
3
x
y
Slide 12
Slide 12 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 12
jgs
Previously | Objects
MyPoint anObject = new MyPoint(1,3); // java
0x73
anObject
1
3
x
y
0x73
Slide 13
Slide 13 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 13
jgs
Previously | Summary
Variable References
Primitive data
(int, float, char …)
Complex data
(arrays, objects,…) *
They store a value They store an address
Slide 14
Slide 14 text
jgs
Data Structures 101
Beyond arrays
Slide 15
Slide 15 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 15
jgs
What is the problem with arrays?
Slide 16
Slide 16 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 16
jgs
What is the problem with arrays?
predefined
size
contiguous
memory
But,
Performance
is good
Slide 17
Slide 17 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 17
jgs
I introduce you a List, a Linked List
Slide 18
Slide 18 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 18
jgs
I introduce you a List, a Linked List
// myGrades = {100, 85, 97, 89}
100
85
97
89
Slide 19
Slide 19 text
jgs
Nuts and bolts of Lists in Java
Nodes
Slide 20
Slide 20 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 20
jgs
Class MyNode
Slide 21
Slide 21 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 21
jgs
Class MyNode
aNode
0x73 1
null
Slide 22
Slide 22 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 22
jgs
Class Node
aNode
0x73 5
null
Slide 23
Slide 23 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 23
jgs
Class Node
aNode
0x73 5
7
null
Slide 24
Slide 24 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 24
jgs
Class Node
fooNode
0
null
aNode
0x73 5
7
null
Slide 25
Slide 25 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 25
jgs
Class Node
aNode
0x73 5
7
null
fooNode
0x11 1
0x73
Slide 26
Slide 26 text
Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 26
jgs
Questions
Slide 27
Slide 27 text
jgs
CSE 205 Object-Oriented Programming and Data Structures
Javier Gonzalez-Sanchez, Ph.D.
[email protected]
Fall 2021
Copyright. These slides can only be used as study material for the class CSE205 at Arizona State University.
They cannot be distributed or used for another purpose.