Slide: 1 Interra Induction Training Data Structure ADT & Complexity.

Slides:



Advertisements
Similar presentations
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
Advertisements

Computational Complexity, Choosing Data Structures Svetlin Nakov Telerik Corporation
David Luebke 1 6/7/2014 CS 332: Algorithms Skip Lists Introduction to Hashing.
Singly Linked Lists What is a singly-linked list? Why linked lists?
David Luebke 1 6/7/2014 ITCS 6114 Skip Lists Hashing.
Linear Lists – Linked List Representation
1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
The ADT Hash Table What is a table?
Hash Tables.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Hash Tables,
Review Pseudo Code Basic elements of Pseudo code
Intro. to Data Structures 1CSCI 3333 Data Structures - Roughly based on Chapter 6.
MATH 224 – Discrete Mathematics
CSE 326: Data Structures Lecture #4 Alon Halevy Spring Quarter 2001.
Lecture # 02 07/02/2013Dr. Muhammad Umair 1. 07/02/2013Dr. Muhammad Umair 2  Numeric  Integer Numbers  0,10,15,4563 etc.  Fractional Number  10.5,
TTIT33 Algorithms and Optimization – Lecture 5 Algorithms Jan Maluszynski - HT TTIT33 – Algorithms and optimization Lecture 5 Algorithms ADT Map,
CSE 332 Review Slides Tyler Robison Summer
CSCE 210 Data Structures and Algorithms
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
TDDB57 DALG-C, DALG Exam Requirements Jan Maluszynski - HT 2006DALG-C.1 TDDB57 – DALG-C Examination Requirements.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Data Structures 1- Course Syllabus. 2- Introduction about 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.
Comp 249 Programming Methodology Chapter 15 Linked Data Structure - Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Week 2 CS 361: Advanced Data Structures and Algorithms
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.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture8.
Lecture 10: Class Review Dr John Levine Algorithms and Complexity March 13th 2006.
Information and Computer Sciences University of Hawaii, Manoa
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Prepared By Ms.R.K.Dharme Head Computer Department.
TECH Computer Science Dynamic Sets and Searching Analysis Technique  Amortized Analysis // average cost of each operation in the worst case Dynamic Sets.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Data Structure Introduction.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
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 Using C++
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
STL – Standard Template Library L. Grewe. 2 Goals Lots of important algorithms, data structures in CS using Templates. is a software library partially.
CISC220 Fall 2009 James Atlas Dec 07: Final Exam Review.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
CS321 Data Structures Jan Lecture 2 Introduction.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Hashing Goal Perform inserts, deletes, and finds in constant average time Topics Hash table, hash function, collisions Collision handling Separate chaining.
1 the BSTree class  BSTreeNode has same structure as binary tree nodes  elements stored in a BSTree are a key- value pair  must be a class (or a struct)
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
CSE373: Data Structures & Algorithms Lecture 5: Dictionary ADTs; Binary Trees Lauren Milne Summer 2015.
1 The Standard Template Library The STL is a collection of Container classes These are class templates for containers. A container is an object that stores.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Final Exam Review COP4530.
CSCE 210 Data Structures and Algorithms
Sections 10.5 – 10.6 Hashing.
CSCI 210 Data Structures and Algorithms
Data Abstraction & Problem Solving with C++
Week 15 – Monday CS221.
DATA STRUCTURES Introduction: Basic Concepts and Notations
Cse 373 April 26th – Exam Review.
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.
Searching.
Final Exam Review COP4530.
Searching CLRS, Sections 9.1 – 9.3.
Final Review Dr. Yingwu Zhu.
COP3530- Data Structures Introduction
Abstract Data Types (ADTs)
Presentation transcript:

Slide: 1 Interra Induction Training Data Structure ADT & Complexity

Slide: 2 CAMP 09 Module Outline Abstract Data Types Fundamentals of Complexity Lower & Upper Bounds What is Complexity ? Examples of Complexity Simple Data Structures Array List/Iterators Stack Queue Trees Terminology Representation Binary Search Tree Standard Optimized – AVL, 2-3-4, Red-Black, B Randomized – BST, Skip List Amortized - Splay Traversals In, Pre, Post order Hash Tables Clustering Collision Resolving Chaining Open Addressing Comparison between two Graphs Terminology Representation Traversals Spanning Trees Data Structures Summary STL Introduction Containers and Iterators slist list Vector pair map hash_map

Slide: 3 CAMP 09 Abstract Data Type (ADT) An ADT comprise three components Domain, D : Set of the data items that the ADT refers to. Operations, F : Set of operations performed on D. Operations can be BASIC or DERIVED Axioms, A : Set of properties that are satisfied by F on D d = (D,F,A) Specification of ADT does not bother about space and time efficiency, those are implementation issues. Data type : a collection of values and and a set of operations on those values

Slide: 4 CAMP 09 Data Structure Defines how the collection of data is to be stored. Data structures may be static or dynamic. More often, a Data Structure provides the CONCRETE view of an ADT and therefore talks of the implementation issues as well. Ex: real numbers: ( integer, integer ) ( sign, exponent, mantissa )

Slide: 5 CAMP 09 Operator Types Accessors : do not change anything. Manipulators : make changes to the data. Iterators : iterate over all elements in the collection. Often there are trade-offs. An ADT may be implemented in several ways. Example: A Stack ADT may be implemented using arrays or lists.

Slide: 6 CAMP 09 Implementation of Data Structure An implementation of a data structure d is a mapping from d to a set of other data structures. The mapping defines how every object of d is represented by the objects of e. it requires that every function of d must be implemeted using the functions defined in e. Ex: real numbers in C float / double.

Slide: 7 CAMP 09 Fundamentals of Complexity Asymptotic Notations Upper bound Lower bound Tight bound What is Complexity ? Examples of Complexity

Slide: 8 CAMP 09 Asymptotic (Upper) : O() for all n > n 0 there exists a function g(n) f(n) constant * g(n) Then upper bound of f(n) is g(n) O-is an Upper Bound for f(n) within a constant factor E.g. 20 = O (n 2 ) 3000*n = O (n 2 ) 15*n 2 = O (n 2 ) 0.1*nlgn = O (n 2 ) *n 3 O (n 2 ) n0n0 c g(n) f(n) n

Slide: 9 CAMP 09 Asymptotic (Lower): () for all n > n 0 there exists a function g(n) constant * g(n) f(n) Then lower bound of f(n) is g(n) - is a Lower Bound for f(n) within a constant factor E.g. 2n 3 + 4n = (n 2 ) n0n0 c g(n) f(n) n

Slide: 10 CAMP 09 Asymptotic (Strict): () for all n > n0 there exists a function g(n) c1 * g(n) f(n) c2 * g(n) Then tight bound of f(n) is g(n) Although (g(n)) is a set, we write f(n) = (g(n)) to indicate that f(n) is a member of (g(n)) E.g. 1/2 n 2 – 3n = (n 2 ) n0n0 c 1 g(n) c 2 g(n) f(n) n

Slide: 11 CAMP 09 What is Complexity? Complexity is an estimate of COST / EFFORT. COST often is Time – usually measured in terms of number of (certain) operations Memory – peak / final Complexity can be Worst Case Average Case Best Case Probabilistic

Slide: 12 CAMP 09 Sorting Complexities

Slide: 13 CAMP 09 Complexity example int *sort(int *inpArr, int n) { int *sortedArr = new int[arrSize]; sortedArr[0] = inpArr[0]; // insert first element for (int i=1; i< n; i++) // rest inserted in sorted order addElem(sortedArr, i, inpArr[i]); return sortedArr; } void addElem(int *sortedArr, int arrSize, int val) { int low=0, high=arrSize-1, mid=high/2; while (high > low) { if (val > sortedArr[mid]) low = mid+1; else if (val < sortedArr[mid] high = mid-1; else { high = low = mid; break; } mid = (high-low)/2 + low; } if (val > sortedArr[mid]) addAtLoc(sortedArr, arrSize, val, mid+1); else addAtLoc(sortedArr, arrSize, val, mid); }

Slide: 14 CAMP 09 Complexity example void addAtLoc(int *sortedArr, int arrSize, int val, int loc) { for (int i=arrSize; i>=loc; i--) { sortedArr[i+1] = sortedArr[i]; } sortedArr[loc] = val; } Assuming time is taken by each assignment is a, comparision is c Worstcase time Complexity of addAtLoc() = arrSize*a+a = a*(arrSize+1) = O(arrSize) Worstcase time Complexity of addElem() = worst complexity of binary search + complexity of addAtLoc() = (2c+2a)*log 2 (arrSize) + c+a*(arrSize+1) = O(arrSize) Worst case Complexity of sort() = n * complexity of addElem() = 3*a + n*c n + n*a + ((2c+2a) *log 2 (arrSize) + c+a*(arrSize+1)) = O(n 2 ) arrSize=1