CSCE 221-200, SPRING 2016 INSTRUCTOR: DR. NANCY M. AMATO 1.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Singly linked lists Doubly linked lists
Stacks.
© 2004 Goodrich, Tamassia Node-Lists1 6.2 Node Lists.
Linked Lists Linked Lists Representation Traversing a Linked List
Lists1 © 2010 Goodrich, Tamassia. Position ADT The Position ADT models the notion of place within a data structure where a single object is stored It.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
Queues 4/14/2017 5:24 PM 5.2 Queues Queues Dr Zeinab Eid.
Data Structures: A Pseudocode Approach with C
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Stacks. 2 Outline and Reading The Stack ADT (§4.2.1) Applications of Stacks (§4.2.3) Array-based implementation (§4.2.2) Growable array-based stack.
Maps. Hash Tables. Dictionaries. 2 CPSC 3200 University of Tennessee at Chattanooga – Summer 2013 © 2010 Goodrich, Tamassia.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data.
1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Stacks. 2 Outline and Reading The Stack ADT (§2.1.1) Array-based implementation (§2.1.1) Growable array-based stack (§1.5) Java.util.Stack class Java.util.Vector.
Part-B1 Stacks. Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations.
Stacks. 2 Outline and Reading The Stack ADT (§2.1.1) Applications of Stacks (§2.1.1) Array-based implementation (§2.1.1) Growable array-based stack (§1.5)
Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
Chapter 3: Arrays, Linked Lists, and Recursion
C++ fundamentals.
Data Structures Using C++ 2E
Stacks and Linked Lists. Abstract Data Types (ADTs) An ADT is an abstraction of a data structure that specifies – Data stored – Operations on the data.
CS212D : DATA STRUCTURES 1 Week 5-6 Linked List. Outline 2  Singly Linked Lists  Doubly Linked Lists  Recursions.
Stacks 1. Stack  What is a stack? An ordered list where insertions and deletions occur at one end called the top. Also known as last-in-first-out (LIFO)
Stack. Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations on the data.
CS261 – Recitation 5 Fall Outline Assignment 3: Memory and Timing Tests Binary Search Algorithm Binary Search Tree Add/Remove examples 1.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Stacks. A stack is a data structure that holds a sequence of elements and stores and retrieves items in a last-in first- out manner (LIFO). This means.
30 May Stacks (5.1) CSE 2011 Winter Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An.
CS 221 Analysis of Algorithms Data Structures Vectors, Lists.
CH 6. VECTORS, LISTS, AND SEQUENCES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH,
CH 8. HEAPS AND PRIORITY QUEUES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
OOP using C Abstract data types How to accomplish the task??? Requirements Details Input, output, process Specify each task in terms of input.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
© 2004 Goodrich, Tamassia Lists1. © 2004 Goodrich, Tamassia Lists2 Position ADT (§ 5.2.2) The Position ADT models the notion of place within a data structure.
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
Parasol Lab, Dept. CSE, Texas A&M University
Welcome to CSCE 221 – Data Structures and Algorithms
CH 6 : VECTORS, LISTS AND SEQUENCES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH,
CH 6 : VECTORS, LISTS AND SEQUENCES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH,
CH 5 : STACKS, QUEUES, AND DEQUES ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Lists1 © 2010 Goodrich, Tamassia. Position ADT  The Position ADT models the notion of place within a data structure where a single object is stored 
CHAPTER 10.1 BINARY SEARCH TREES    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
CH 1-4 : INTRODUCTION ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND.
C++ Programming:. Program Design Including
Vectors 5/31/2018 9:25 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Ch7. List and Iterator ADTs
EEL 4854 IT Data Structures Linked Lists
Lecture 2 of Computer Science II
LINKED LISTS CSCD Linked Lists.
Object-Oriented Programming
Stacks.
Ch. 8 Priority Queues And Heaps
Linked Lists.
Doubly Linked Lists or Two-way Linked Lists
CS212D: Data Structures Week 5-6 Linked List.
Problem Understanding
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
CH 9 : Maps And Dictionary
Introduction to Data Structure
Oriented Design and Abstract Data Type
Presentation transcript:

CSCE , SPRING 2016 INSTRUCTOR: DR. NANCY M. AMATO 1

SYLLABUS, COURSE ORGANIZATION & ASSIGNMENTS  Course Webpage:  Syllabus:  Assignments and Activites: https//parasol.tamu.edu/~amato/assignments.php:https//parasol.tamu.edu/~amato/assignments.php  Culture  Programming  Homework  In Class Activities (ICAs) and In Lab Activities (ILAs) 2

CH 1-4 : INTRODUCTION ACKNOWLEDGEMENT: THESE SLIDES INCLUDE INPUT FROM SLIDES PROVIDED WITH ``DATA STRUCTURES AND ALGORITHMS IN C++’’, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM JORY DENNY 3

OBJECT ORIENTED DESIGN (CH 2)  Object Oriented Design and Principles  Abstract Data Types  Encapsulation  Inheritance  Polymorphism  Exceptions 4

OBJECT ORIENTED DESIGN AND PRINCIPLES (CH 2.1)  Design Goals:  Robustness : Capability to handle any type of inputs  Adaptability : Can be used in various environments with minimal or no changes  Reusability : Same code can be used as a component in various applications over time  Design Principles:  Abstraction: Abstract the complicated details in form of fundamental parts and operations  Encapsulation: Coupling data with methods.  Modularity: Component based design  Inheritance: Hierarchical and “is-a type-of” relationship  Polymorphism: Ability to take different form 5

ABSTRACT DATA TYPE (ADT)  An abstract data type (ADT) is an abstraction of a data structure  An ADT specifies:  Data stored  Operations on the data  Error conditions associated with operations  Mathematical model only with no details about the implementation :  ADT specifies what each operation does not how it does it.  Example: ADT modeling a simple stock trading system  The data stored are buy/sell orders  The operations supported are  order buy(stock, shares, price)  order sell(stock, shares, price)  void cancel(order)  Error conditions:  Buy/sell a nonexistent stock  Cancel a nonexistent order 6

ENCAPSULATION  Bundling of data and associated methods as a type.  Hiding the details and direct access to the underlying data.  Class: Construct or the definition of encapsulated data and associated methods. User-defined types.  class Person { private: string name; public: string GetName() { return name; } void SetName( string _n) { name = _n; } }  Object: Instance of an object  Person A; // A is an object of class Person or in other words type of A is Person 7

INHERITANCE  Hierarchical organization of classes.  Base class: The class from which another class is inherited.  Derived class: The class that inherits  Abstract classes: Base class with one or more virtual member functions  Virtual member functions are abstract functions with no details. 8 Shape CircleTriangleSquare

POLYMORPHISM  Different types of a variable  Subtyping : Type of the variable is determined at runtime based on the instance.  Eg: Shape* newShape = new Circle(); newShape->draw(); //Will call draw() function of Circle class and not of the Shape class.  Parametric: Generics (templates) where code is written without any specific type.  Eg: template T sum ( T a, T b) {} // Can be used as sum (3,4) and sum (4.5, 7.8) 9

EXCEPTIONS (CH 2.4)  Attempting the execution of an operation of ADT may sometimes cause an error condition, called an exception  Exceptions are said to be “thrown” by an operation that cannot be executed  Example: removing an element from an empty container 10

ARRAYS AND LINKED LISTS (CH 3)  Arrays (Ch 3.1)  Singly Linked List (Ch 3.2)  Doubly Linked (Ch 3.3) 11

ARRAYS  Data structure containing a collection of same type  Contiguous allocation in memory  Limitation: The length or capacity of the array is fixed.  Easy Random Access through index of the element (position of the element with respect to the first element in the array. Eg. A[3] indicates fourth element if the first element is stored in index 0.  Insertions and deletion at arbitrary location would include rearrangement of the elements following the location. Eg. Removing an element at index 6 would involve moving elements at indices 7,8,9 to 6,7,8. 12

SINGLY LINKED LIST  A singly linked list is a concrete data structure consisting of a sequence of nodes  Each node stores  element  link to the next node  No contiguous allocation of memory  Accessing an element at an arbitrary location includes traversing the list from the first element. next elem node ABCD  13

DOUBLY LINKED LIST  A doubly linked list provides a natural implementation of the Node List ADT  Nodes implement Position and store:  element  link to the previous node  link to the next node  Special trailer and header nodes  No contiguous allocation of memory  Access at arbitrary position requires traversal of the list  Easy insertion and deletion of element  If the pointer to the element is known trailer header nodes/positions elements prevnext elem node 14

EXERCISE: ARRAYS, SINGLY LINKED LIST, DOUBLY LINKED LIST 15  Describe how you would reach/access the third element in a data structure if it were a  Array  Singly Linked List  Doubly Linked List  Would your answer change if we wanted to reach/access the last element in the data structure? If so, how?

EXERCISE: COMPLETE THE TABLE WITH THE COMPLEXITY OF THESE OPERATIONS ArraySingly Linked ListDoubly Linked List Access first element Access last element Access middle element 16

EXERCISE: COMPLETE THE TABLE WITH THE COMPLEXITY OF THESE OPERATIONS ArraySingly Linked ListDoubly Linked List Access first element Access last element Access middle element 17