Data structures and algorithms

Slides:



Advertisements
Similar presentations
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
Advertisements

1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
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 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 1, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 1: Introduction What this course is about:  Data.
DATA STRUCTURE Subject Code -14B11CI211.
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.
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.
Pointers OVERVIEW.
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.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
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.
Lecture 7 : Intro. to STL (Standard Template Library)
Data Structures for Midterm 2. C++ Data Structure Runtimes.
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.
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.
Code: BCA302 Data Structures with C Prof.(Dr.) Monalisa Banerjee By.
Lecture 1 Data Structures Aamir Zia. Introduction Course outline Rules and regulations Course contents Good Programming Practices Data Types and Data.
Advanced Data Structures Lecture 1
Introduction toData structures and Algorithms
CSCE 210 Data Structures and Algorithms
Data Structure By Amee Trivedi.
Course Developer/Writer: A. J. Ikuomola
Data Structures Michael J. Watts
Top 50 Data Structures Interview Questions
Standard Template Library
The Design and Analysis of Algorithms
Data Structure Interview Question and Answers
MIS 215 Module 1 – Unordered Lists
Data Abstraction & Problem Solving with C++
Exam Hints.
Standard Template Library (STL)
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.
STACKS AND QUEUES UNIT 2 DS THROUGH C++.
Programming Abstractions
Hashing Exercises.
abstract containers sequence/linear (1 to 1) hierarchical (1 to many)
Searching.
Prof. Michael Neary Lecture 7: The STL Prof. Michael Neary
structures and their relationships." - Linus Torvalds
Stacks, Queues, and Deques
structures and their relationships." - Linus Torvalds
Stacks, Queues, and Deques
Objective of This Course
Data Structures and Algorithms
PAC Intro to “big o” Lists Professor: Evan Korth New York University
Introduction to Data Structure
By Yogesh Neopaney Assistant Professor Department of Computer Science
DATA STRUCTURE.
Standard Template Library
Hash-Based Indexes Chapter 11
CS210- Lecture 16 July 11, 2005 Agenda Maps and Dictionaries Map ADT
Stacks, Queues, and Deques
(1 - 2) Introduction to C Data Structures & Abstract Data Types
Introduction to data structures
Standard Template Library
Introduction to data structures
CSCE156: Introduction to Computer Science II
structures and their relationships." - Linus Torvalds
Presentation transcript:

Data structures and algorithms Lecture 1: Introduction What this course is about: Data structures & algorithms ADT Algorithm analysis Additional of C++

What about data structures Structure: how data is organized Place data contiguously Place data here and there with “links” Place data with “formula”

What about algorithms 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

Basic data types – the simplest data structure Basic data types a language supports: Integer, float, double, char, boolean string: usually an array of char supported with library

Basic Data structures A single datum in one of the basic types A structure is a combination of the basic types A Publication: code—string, description—string, price– double A structure is a combination of basic types and structures An Order item: publication—Publication, quantity– integer, deleteFlag – boolean

Storage Container For storing multiple occurrences of a structure Contiguous structures: Array – supported by a language but needs 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

Examples of storage containers

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.

ADT In C++ or Java, an ADT can be implemented as a class. 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.

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; …… }; reSize() “automatically” re-defines an array according to the structure defined in Vector. There can be more: copy(), insert(), etc

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 Data can be stored in the basic storage containers in any order but they must be sorted before applying binary search

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

Algorithm not related to a restrictive structure E.g., Linear search can find the maximum & minimum: 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 Can it be faster without sorting the container? How about comparing max with the greater one of each pair in the container.

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 or may not relate to a data structure

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

Algorithms in this course Other than basic algorithms related to the data structures in this course, in order to have better algorithms and algorithm analysis, some sorting methods will be studied, e.g., : Selection sort Insertion sort Merge sort Quick sort

Additional to C++ Extend the study of DO10105 in: Using more STL’s classes Using pointers for “linked” structures Using reference for better implementation

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

Reference -- END --