Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE205 Lecture 16

CSE205 Lecture 16

Object-Oriented Programming and Data Structures
Data Structures I
(202110)

Javier Gonzalez-Sanchez
PRO

September 26, 2021
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. 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

    View Slide

  2. jgs
    Previously on
    Programming 101 (and Java fundamentals)

    View Slide

  3. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 3
    jgs
    Previously

    View Slide

  4. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 4
    jgs
    Previously
    byte

    View Slide

  5. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 5
    jgs
    Previously
    0x01 0x02
    0xE6 0xE7

    View Slide

  6. 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

    View Slide

  7. 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

    View Slide

  8. 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

    View Slide

  9. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 9
    jgs
    Previously | Arrays
    int[] myGrades = new int[3];
    myGrades[0]= 100;
    myGrades[1]= 85;
    myGrades[2]= 97;
    // java
    0x73 0x77 0x7B
    100
    myGrades
    85 97

    View Slide

  10. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 10
    jgs
    Previously | Reference
    // java
    0x11 0x73 0x77 0x7B
    100
    myGrades
    85 97
    0x73
    int[] myGrades = new int[3];
    myGrades[0]= 100;
    myGrades[1]= 85;
    myGrades[2]= 97;

    View Slide

  11. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 11
    jgs
    Previously | Objects
    MyPoint anObject = new MyPoint(1,3); // java
    0x73
    anObject
    1
    3
    x
    y

    View Slide

  12. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 12
    jgs
    Previously | Objects
    MyPoint anObject = new MyPoint(1,3); // java
    0x73
    anObject
    1
    3
    x
    y
    0x73

    View Slide

  13. 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

    View Slide

  14. jgs
    Data Structures 101
    Beyond arrays

    View Slide

  15. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 15
    jgs
    What is the problem with arrays?

    View Slide

  16. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 16
    jgs
    What is the problem with arrays?
    predefined
    size
    contiguous
    memory
    But,
    Performance
    is good

    View Slide

  17. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 17
    jgs
    I introduce you a List, a Linked List

    View Slide

  18. 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

    View Slide

  19. jgs
    Nuts and bolts of Lists in Java
    Nodes

    View Slide

  20. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 20
    jgs
    Class MyNode

    View Slide

  21. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 21
    jgs
    Class MyNode
    aNode
    0x73 1
    null

    View Slide

  22. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 22
    jgs
    Class Node
    aNode
    0x73 5
    null

    View Slide

  23. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 23
    jgs
    Class Node
    aNode
    0x73 5
    7
    null

    View Slide

  24. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 24
    jgs
    Class Node
    fooNode
    0
    null
    aNode
    0x73 5
    7
    null

    View Slide

  25. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 25
    jgs
    Class Node
    aNode
    0x73 5
    7
    null
    fooNode
    0x11 1
    0x73

    View Slide

  26. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 26
    jgs
    Questions

    View Slide

  27. 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.

    View Slide