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

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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size 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 full-size 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 full-size 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 full-size 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 full-size 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 full-size slide

  14. jgs
    Data Structures 101
    Beyond arrays

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size 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 full-size slide

  19. jgs
    Nuts and bolts of Lists in Java
    Nodes

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide