structures and their relationships." - Linus Torvalds

Slides:



Advertisements
Similar presentations
Data Structures.
Advertisements

Computer Science 112 Fundamentals of Programming II Overview of Collections.
CS Data Structures II Review COSC 2006 April 14, 2017
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
CS102 – Data Structures Lists, Stacks, Queues, Trees, Hash Collections Framework David Davenport Spring 2002.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
Chapter 12 Collections. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Collections A collection is an object that helps us organize and manage.
CS 307 Fundamentals of Computer Science ADTS and Generic Data Structures 1 Topic 12 ADTS, Data Structures, Java Collections and Generic Data Structures.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Lists Based on content from: Java Foundations, 3rd Edition.
Computer Science Department Data Structures and Algorithms Lecture 1.
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
9-1 Abstract Data Types Abstract data type A data type whose properties (data and operations) are specified independently of any particular implementation.
Data structures Abstract data types Java classes for Data structures and ADTs.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
1 Stacks (Continued) and Queues Array Stack Implementation Linked Stack Implementation The java.util.Stack class Queue Abstract Data Type (ADT) Queue ADT.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
2 Obaid Ullah HOD Computer Science Dept. Superior University Sialkot Campus.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Using the Java Collection Libraries COMP 103 # T2
Understanding Algorithms and Data Structures
12 Collections Software Solutions Lewis & Loftus java 5TH EDITION
G64ADS Advanced Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Course Developer/Writer: A. J. Ikuomola
Data Structures Michael J. Watts
Fundamentals of Programming II Overview of Collections
Marcus Biel, Software Craftsman
Data Structure Interview Question and Answers
Chapter 15 Lists Objectives
Heaps And Priority Queues
Chapter 12: Data Structures
Basic Data Structures.
Data Structures Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective.
Cinda Heeren / Geoffrey Tien
Week 15 – Monday CS221.
Programming Abstractions
Hashing Exercises.
Cse 373 April 26th – Exam Review.
Introduction to Data Structure
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Road Map CS Concepts Data Structures Java Language Java Collections
CS313D: Advanced Programming Language
structures and their relationships." - Linus Torvalds
Java Collections Framework
- Alan Perlis Topic 24 Heaps "You think you know when you can learn,
ITEC 2620M Introduction to Data Structures
Lesson 6. Types Equality and Identity. Collections.
Priority Queues & Heaps
Introduction to Data Structure
Road Map CS Concepts Data Structures Java Language Java Collections
Fundaments of Game Design
OPIM 915 Fall 2010 Data Structures 23-38,
CO4301 – Advanced Games Development Week 12 Using Trees
structures and their relationships." - Linus Torvalds
Abstract Data Types (ADTs)
Presentation transcript:

structures and their relationships." - Linus Torvalds Data Structures "Bad programmers worry about the code. Good programmers worry about data structures and their relationships."   - Linus Torvalds

CS 221 - Computer Science II Data Structures A Data Structure is: “an organization of information, usually in computer memory, for better algorithm efficiency." CS 221 - Computer Science II

Data Structure Concepts Data Structures are containers. They hold other data. Arrays are a data structure. So are linked lists. Other types of data structures: stack, queue, tree, binary search tree, hash table, dictionary or map, set, … en.wikipedia.org/wiki/List_of_data_structures Different types of data structures are optimized for certain types of operations. CS 221 - Computer Science II

CS 221 - Computer Science II Core Operations Data Structures have three core operations: A way to add things. A way to remove things. A way to access things, without modifying the data structure. Details depend on the data structure. For instance, a List data structure may need to: add at the end of the List. access by data by position. remove by data by position. More operations are added depending on what data structure is designed to do. CS 221 - Computer Science II

Types of Data Structures Implementation-Dependent Implementation-Independent Arrays Linked Structures Linked Lists Trees Indexed Lists Sets Queues Bags Stacks CS 221 - Computer Science II

Implementation-Dependent Data Structures Arrays Collection of objects stored contiguously in memory. Accessed by index. Linked Structures Collection of node objects. Store data and reference to one or more other nodes. Linked Lists Linear collection of nodes. Single-linked List – nodes contain references to next node in list. Double-Linked List – nodes contain reference to next and previous nodes in list. Trees Hierarchical structure. Nodes reference two or more “children.”

Implementation-Independent Data Structures Abstract Data Types (ADTs): Descriptions of how a data type will work without implementation details. Description can be a formal, mathematical description. Many Java interfaces are a form of ADTs. Examples: Bag, Set, Stack, Queue, Indexed List, etc. CS 221 - Computer Science II

CS 221 - Computer Science II Implementing ADTs The operations and behaviors are already specified. For instance, every Stack has push, pop and peek methods. Think Java interface. But given an interface describing an ADT, how implement it? Must decide which internal storage container to use to hold the items in the ADT. Currently, few choices: arrays anyone? Later add linked structures. CS 221 - Computer Science II

CS 221 - Computer Science II Bags and Sets Simplest ADT is a Bag Items can be added, removed, accessed. No implied order to the items. Duplicates allowed. Set ADT Same as a bag, except duplicate elements not allowed. Operations: union, intersection, difference, subset, etc. CS 221 - Computer Science II

CS 221 - Computer Science II Stack ADT Can only access last item inserted. Expected behavior: Last in, First out (LIFO) push - put object on top of Stack pop - remove object from top of Stack peek or top - look at object on top of the Stack Other useful operations: make empty size is empty? CS 221 - Computer Science II

CS 221 - Computer Science II Queue ADT Can only access item that has been there the longest. Expected behavior: First in, First out (FIFO) enqueue - insert at the back of the Queue dequeue - remove from the front of the Queue front - look at the object at the front of the Queue Other useful operations: make empty size is empty? CS 221 - Computer Science II

CS 221 - Computer Science II List ADTs Linear collection of items. Sorted List Items in list are arranged in a pre-determined ordering. For instance, alphabetically or by ascending numerical value. Indexed List Items are accessed by position in list. Additions / deletions can also be done by position. Unsorted List Items are stored without an implicit ordering. CS 221 - Computer Science II

CS 221 - Computer Science II Tree ADTs Binary Search Trees (BSTs) Items stored in sorted order. Heaps Items stored according to the “Heap Property.” AVL and Red-Black Trees BSTs that stay balanced. Splay Trees BST with most recently items at top. B-Trees Another variation of BST. Nodes can have more than two children. CS 221 - Computer Science II

CS 221 - Computer Science II Other ADTs Hash Tables Hash function: Computes an index into an array of buckets or slots. Look in the bucket for the desired value. Maps Collection of items with a key and associated values. Similar to hash tables. Graphs Nodes with unlimited connections between other nodes. Sparse vectors and sparse matrices. CS 221 - Computer Science II

CS 221 - Computer Science II Generic Containers All data structures in Java, including ADTs, should be generic. Write them once, use lots of times. Hold many different types of data. Java achieves genericity through inheritance and polymorphism. CS 221 - Computer Science II

CS 221 - Computer Science II Internal Storage ADTs have an internal storage container. What is storing the stuff? Usually one of the Implementation-Dependent Data Structures: Arrays, Linked Lists, Trees Abstraction vs. Implementation Have to consider: abstraction - how data structure interacts with other classes. implementation - how is the data actually being stored. CS 221 - Computer Science II

ADTs and Data Structures in Programming Languages Modern programming languages usually have a library of ADTs. Java collections framework C++ standard template library .Net framework (portion of VERY large library) Python lists and tuples Lisp lists However, most provided collection classes aren’t pure ADTs. CS 221 - Computer Science II

CS 221 - Computer Science II ADTs in Java Part of the Java Standard Library is the Collections Framework. A library of data structures Built on two interfaces Collection Iterator http://java.sun.com/j2se/1.5.0/docs/guide/collections/index.html CS 221 - Computer Science II

CS 221 - Computer Science II

Stacks and Queues in the Java Collection API No queue class in the Java collections API. Can implement Queue interface using Java LinkedList class. Stack extends Vector (which is almost exactly like ArrayList). Hmmm? One reason the Java Collections Library is often said to be broken. CS 221 - Computer Science II