Data Structures: Linked Lists

Objects and classes

Building a social network

Suppose you're in the year 2004 and had this great idea...

You decide you want to build the basic data infrastructure of your website first

The first step on your road to success, fame and $$$

You decide you want to build the basic data infrastructure of your website first

Now you want to test your software with fake data

You want to test your software with randomly generated people

To do this, you would like to generate a social network with randomly generated Person objects, each one with randomly assigned firends

Now that you have a simulated social network, you are ready for pitching your idea

You want to generate silly statistics that would attract investors to your new startup

Data structures

Data structures are a way of organizing collections of data in the computer's memory

Data structures

Data structures are a way of organizing collections of data in the computer's memory

Examples of data structures we have seen so far
  • Arrays

Data structures

Data structures are a way of organizing collections of data in the computer's memory

Examples of data structures we have seen so far
  • Objects

Data structures

Data structures are a way of organizing collections of data in the computer's memory

Examples of data structures we have seen so far
  • Networks of cities (Assignment 4), a social network (last class)

Data structures

Data structures are a way of organizing collections of data in the computer's memory

Examples of data structures we have seen so far
  • Arrays
  • Objects
  • Networks of cities (Assignment 4), a social network (last class)
  • Linked Lists (today's class)

Linked Lists

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using the Person objects from the social network

Linked Lists

This is a visual representation of a linked list using int values

Going through the components of a LinkedList

We need to define a class for each element in the list: the Node class

The Node class should have:

Going through the components of a LinkedList

We need to define a class for doing operations on the list: the LinkedList class

The LinkedLsit class should have:

Inserting elements in a linked list

Resources

/