Rossella Lau Lecture 1, DCO20105, Semester A,2004-5 DCO 20105 Data structures and algorithms  Lecture 1: Introduction What this course is about:  Data.

Slides:



Advertisements
Similar presentations
M The University Of Michigan Andrew M. Morgan EECS Lecture 22 Savitch Ch. 16 Intro To Standard Template Library STL Container Classes STL Iterators.
Advertisements

SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
Data Structures Michael J. Watts
Templates and the STL Bryce Boe 2012/09/10 CS32, Summer 2012 B.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
Rossella Lau Lecture 11, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 11: Template and Operator overload  Template.
Rossella Lau Lecture 5, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 5: Deque Comparison of sequence containers  Deque.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
Rossella Lau Lecture 8, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 8: Polymorphism & C++ pointer  Inheritance.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Rossella Lau Lecture 1, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 1: Introduction What this course is about:  Data.
Rossella Lau Lecture 3, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 3: Basics of Linked List  C++ pointer revision.
Rossella Lau Lecture 7, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 7: Big-O analysis Sorting Algorithms  Big-O analysis.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Rossella Lau Lecture 2, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 2: Vector  Array and vector  Internal structure.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
C++ Programming: Program Design Including Data Structures, Second Edition Chapter 22: Standard Template Library (STL)
Rossella Lau Lecture 4, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 4: C++ and list  Usage of Vector and List  C++
Rossella Lau Lecture 12, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 12: An Introduction to the STL  Basic.
DATA STRUCTURE Subject Code -14B11CI211.
Data Structures Lecture-1:Introduction
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.
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Data Structures Using C++ 2E
Design and Analysis of Algorithms CSC201 Shahid Hussain 1.
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.
Java Collections An Introduction to Abstract Data Types, Data Structures, and Algorithms David A Watt and Deryck F Brown © 2001, D.A. Watt and D.F. Brown.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
Generic Programming Using the C++ Standard Template Library.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
General Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
Pointers OVERVIEW.
Software Design 1.1 Tapestry classes -> STL l What’s the difference between tvector and vector  Safety and the kitchen sink What happens with t[21] on.
Overview of Course Java Review 1. This Course Covers, using Java Abstract data types Design, what you want them to do (OOD) Techniques, used in implementation.
CSC 212 – Data Structures Lecture 37: Course Review.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Tirgul 11 Notes Hash tables –reminder –examples –some new material.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Lecture 7 : Intro. to STL (Standard Template Library)
Hashtables. An Abstract data type that supports the following operations: –Insert –Find –Remove Search trees can be used for the same operations but require.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
C++ Review STL CONTAINERS.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Copyright © 2009 Curt Hill Look Ups A Recurring Theme.
CSC 143T 1 CSC 143 Highlights of Tables and Hashing [Chapter 11 p (Tables)] [Chapter 12 p (Hashing)]
Unit VI.  C++ templates are a powerful mechanism for code reuse, as they enable the programmer to write code (classes as well as functions) that behaves.
CSCE 210 Data Structures and Algorithms
Data Abstraction & Problem Solving with C++
Standard Template Library (STL)
structures and their relationships." - Linus Torvalds
structures and their relationships." - Linus Torvalds
Data Structures and Algorithms
Data structures and algorithms
Introduction to Data Structure
By Yogesh Neopaney Assistant Professor Department of Computer Science
CS2013 Lecture 7 John Hurley Cal State LA.
Standard Template Library
Standard Template Library
structures and their relationships." - Linus Torvalds
Presentation transcript:

Rossella Lau Lecture 1, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 1: Introduction What this course is about:  Data structures & algorithms  ADT  Algorithm analysis  C++ -- By Rossella Lau

Rossella Lau Lecture 1, DCO20105, Semester A, What about data structures and algorithms  Structure: how data is organized  Place data contiguously  Place data here and there with “links”  Place data with “formula”  Algorithms: how to access data for a result  Scan data sequentially  Scan data according to the sequence of a structure  Scan data with “formula”  Algorithms: how to provide a smart solution

Rossella Lau Lecture 1, DCO20105, Semester A, Basic data structures  Basic data types a language supports:  Integer, float, double, char, boolean  string: usually an array of char supported with library  Data structures  A single datum in one of the basic types  A structure is a combination of the basic types A Product: code—string, description—string, price– double  A structure is a combination of basic types and structures A Sales: product—Product, quantity– integer

Rossella Lau Lecture 1, DCO20105, Semester A, Storage Container For storing multiple occurrences of a structure  Contiguous structures:  Array – supported by a language but needed care of array size, overflow  Vector – a structure to allow handling of its size and overflow “automatically”  Linked List: allow data connected by “links” to save space which may be wasted in an array/vector.  Combination of vector and linked list

Rossella Lau Lecture 1, DCO20105, Semester A,  reSize() “automatically” re-defines an array according to the structure defined in Vector.  There can be more: copy(), insert(), etc Algorithms A simplified view: clear process steps  E.g., A vector reSize(int newSize) { Define a new array with newSize if newSize >= capacity Copy the contents from *array to the new array Assign newSize to capacity Make the new array as *array Throw away the old array } class Vector{ int *array; int size; int capacity; …… };

Rossella Lau Lecture 1, DCO20105, Semester A, ADT An abstract model of a data structure together with the operations (can be treated as a form of algorithms) processed on the data structure.  In C++ or Java, an ADT can be implemented as a class.  Examples of the storage containers: vector and list (Text book slides: 1.4-8)

Rossella Lau Lecture 1, DCO20105, Semester A, Notes on the basic storage containers Vector and list allow data to be stored in different ways but not restricted to any order, or any operations, e.g.,  Data can be ordered in any sequence, even though searching may prefer a sorted one.  Operations support inserting an element in between elements of a vector, even though it may involve a lot of “shift” operations.

Rossella Lau Lecture 1, DCO20105, Semester A, Algorithms with “restrictive” containers When data in containers are organized with some kind of restriction, algorithms may be improved in many cases  E.g., sequential search and binary search ( Text book slides: )  Data can be stored in the basic storage containers in any order but they must be sorted before applying binary search

Rossella Lau Lecture 1, DCO20105, Semester A, Data structures in this course Many kinds of known containers allow “better” algorithms to be applied. In this course, we will look at some basic containers:  Vector, List, Deque  Map (Binary Search Tree)  Hash map  Stack and Queue

Rossella Lau Lecture 1, DCO20105, Semester A, Algorithm not related to a restrictive structure E.g., Linear search can find the maximum & minimun:  Can it be faster without sorting the container?  How about comparing max with the greater one of each pair in the container. int min = max = at(0).getValue; for (int i=1; i<siz(); i++) { if ( at(i).getValue > max ) max = getValue; if ( at(i).getValue < min ) min = getValu; } } // max and min is the result

Rossella Lau Lecture 1, DCO20105, Semester A, Algorithm at “low level” E.g., Use “cheaper” operations or better formula to achieve better execution time  int valueA / 2; can be rewritten as int valueA >> 1;  if ( value % 2 ) can be rewritten as if ( value & 1 )  We look for “smart” algorithms which may be or may not be related to a data structure

Rossella Lau Lecture 1, DCO20105, Semester A, Algorithm analysis To understand how good or how bad an algorithm is  Theoretically evaluate an algorithm  Execution time  Storage efficiency  Experimentally evaluate an algorithm  Use system clock to measure the execution time

Rossella Lau Lecture 1, DCO20105, Semester A, Algorithms in this course Other than basic algorithms related to the data structures in this course, in order to better algorithms and algorithm analysis, some sorting methods will be studied, e.g., :  Selection sort  Insertion sort  Merge sort  Quick sort

Rossella Lau Lecture 1, DCO20105, Semester A, C++  An O-O language for this course  Powerful, flexible  With a Standard Library and a Standard Template Library  Students can learn one more language in the programme  Major differences with Java  Not necessary to be a class inside a program  Using template much more than polymorphism  An object can be referenced in three forms: a real object, a pointer (including iterators), and a reference.

Rossella Lau Lecture 1, DCO20105, Semester A, Summary  This course studies basic data structures and algorithms with C++ implementation  Organization of a data structure may allow better algorithms to be applied  Algorithms can be smarter without a special organization of a data structure  There are ways to measure or evaluate an algorithm

Rossella Lau Lecture 1, DCO20105, Semester A, Reference  Ford: 1.2-3, 3.2  C++ Complete Reference  Lecture 1 of last year -- END --