This presentation talks about data structures, how linked lists work and how to implement them using object oriented programming.
Size: 235.27 KB
Language: en
Added: Mar 15, 2016
Slides: 13 pages
Slide Content
DATA STRUCTURES
Data Structures A way of organizing data so that it can be used efficiently. Choice of data structure determines how efficiently the program runs. Choosing a data structure depends on data operations and frequency. Each data structure requires space for storage, time for operations
Data Structure Examples - Stack
Data Structure Examples - Queue
Data Structure Examples – Linked Lists NULL DATA NEXT DATA NEXT DATA NEXT DATA
Linked List and Nodes NULL DATA NEXT DATA NEXT DATA NEXT DATA NEXT DATA A Node Object { Variable to hold data; Variable to hold next reference; } VALUE REFERENCE
Adding to a list NULL DATA NEXT DATA NEXT DATA NEXT DATA Last In First Out NULL DATA NEXT DATA NEXT DATA NEXT DATA First In Last Out ADDED FIRST ADDED LAST ADDED FIRST ADDED LAST
Adding the first node NULL DATA Create an object of type Node which contains value for data and whose next reference value is null NULL DATA FIRST 2. Store the reference to this newly created object in a variable.
Adding subsequent nodes NULL DATA Create an object of type Node which contains value for data and whose next reference value is null NEXT DATA FIRST Append this new node before or after the current node. Update the NEXT and FIRST references. NULL DATA
Inserting node NEXT DATA NEXT DATA FIRST NULL DATA NULL DATA NEXT
Removing first node NEXT DATA FIRST NEXT DATA NULL DATA FIRST
Removing specific node NEXT DATA NULL DATA CURRENT NEXT DATA NEXT DATA PREVIOUS CURRENT CURRENT PREVIOUS Match? Match? FOUND!! Match?
What we talked about Data structures and why we need them How linked lists work Adding and removing from a linked list