Lecture 10: Class Review Dr John Levine 52236 Algorithms and Complexity March 13th 2006.

Slides:



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

Chapter 1: INTRODUCTION TO DATA STRUCTURE
PROGRAMMING LANGUAGE (JAVA) UNIT 42 BY ROBERT BUTTERFIELD TELEPHONE Data Structures and Algorithms.
The Dictionary ADT Definition A dictionary is an ordered or unordered list of key-element pairs, where keys are used to locate elements in the list. Example:
Data Structures Using C++ 2E
Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
Fundamentals of Python: From First Programs Through Data Structures
Data Structures, Search and Sort Algorithms Kar-Hai Chu
CSCE 210 Data Structures and Algorithms
Data Structures & Algorithms What The Course Is About s Data structures is concerned with the representation and manipulation of data. s All programs.
CS 206 Introduction to Computer Science II 10 / 15 / 2008 Instructor: Michael Eckmann.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
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.
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.
Teaching Teaching Discrete Mathematics and Algorithms & Data Structures Online G.MirkowskaPJIIT.
ICS220 – Data Structures and Algorithms Lecture 10 Dr. Ken Cosh.
Comp 249 Programming Methodology Chapter 15 Linked Data Structure - Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
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.
A Level Computer Science Topic 9: Data Structures T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen.
Design and Analysis of Algorithms CSC201 Shahid Hussain 1.
Week 11 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Course Web Page Most information about the course (including the syllabus) will be posted on the course wiki:
Information and Computer Sciences University of Hawaii, Manoa
Analysis of Algorithms
Final Review Dr. Yingwu Zhu. Goals Use appropriate data structures to solve real- world problems –E.g., use stack to implement non-recursive BST traversal,
Week 6 - Friday.  What did we talk about last time?  Recursive running time  Fast exponentiation  Merge sort  Introduced the Master theorem.
Prepared By Ms.R.K.Dharme Head Computer Department.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
“Enthusiasm releases the drive to carry you over obstacles and adds significance to all you do.” – Norman Vincent Peale Thought for the Day.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
Data Structure Introduction.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
Hashtables. An Abstract data type that supports the following operations: –Insert –Find –Remove Search trees can be used for the same operations but require.
Course Review Fundamental Structures of Computer Science Margaret Reid-Miller 29 April 2004.
Hash Tables © Rick Mercer.  Outline  Discuss what a hash method does  translates a string key into an integer  Discuss a few strategies for implementing.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Review Sorting algorithms Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
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.
Searching Topics Sequential Search Binary Search.
DATA STRUCTURES (CS212D) Overview & Review Instructor Information 2  Instructor Information:  Dr. Radwa El Shawi  Room: 
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Course Review Fundamental Structures of Computer Science Margaret Reid-Miller 28 April 2005.
Data Structure and Algorithms
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
1 i206: Lecture 17: Exam 2 Prep ; Intro to Regular Expressions Marti Hearst Spring 2012.
CSCE 210 Data Structures and Algorithms
Course Developer/Writer: A. J. Ikuomola
Data Structure Interview Question and Answers
Week 15 – Monday CS221.
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.
Abstract Data Types (ADTs)
CSE 373 Data Structures and Algorithms
Introduction to Data Structures
Introduction to Data Structure
COP3530- Data Structures Introduction
Presentation transcript:

Lecture 10: Class Review Dr John Levine Algorithms and Complexity March 13th 2006

Today’s Lecture More notes on Practical 1: some example graphs Syllabus review for this class Topics covered by this class and which topics are examinable Topics remaining to be covered: Abstract data types, hash tables, graph algorithms, NP-hard problems Abstract data types and an example Hash tables (from Mark Dunlop’s slides)

More Notes on Practical 1 public class Test7 { public static void main (String[] args) { int sum = 0; int n = (int)Double.parseDouble(args[0]); long startTime = System.currentTimeMillis(); for (int i=0; i<n; i++) for (int j=0; j<i*i; j++) if (j%i == 0) for (int k=0; k<j; k++) sum++; long endTime = System.currentTimeMillis(); }

How to do it Find a value of n that gives a small, but non-zero time (e.g. around milliseconds) Find a value of n that gives a fairly large time (depends how long you can bear to wait – about 5-10 seconds) Sample values of n between these two values Try fitting various trend lines: linear, polynomial, etc. Look for a high R 2 value showing goodness of fit If you analysis says (for example) O(n 3 ), try plotting your time values against n 3 and look for a straight line

Learning Outcomes On completion of the class, a student should be able: to implement a number of fundamental algorithms, including in particular the fundamental algorithms of searching and sorting to make a critical assessment of different implementations of algorithms and abstract data types to carry out a number of empirical studies of the performance of algorithms and abstract data types to appreciate a number of fundamental computational problems, and be aware of real world instances of those problems

Syllabus: Algorithmic Complexity Introduction to Algorithmic Complexity: basic algorithmic classification, with examples; the order notation (Big-oh); elementary complexity and estimation of run times; the tyranny of growth. Covered in specifically in Lectures 1 and 2 and Practical 1, also covered throughout the course Examinable Typical exam question: say what Big-oh is, give an analysis of some code fragments

Syllabus: Searching and Sorting Searching and Sorting: the complexity of a range of techniques, including the divide and conquer approach; the relative complexity of searching and sorting algorithms; the sorting algorithms covered will include bubble sort, insertion sort, merge sort and quick sort; searching, including sequential search and the binary chop; hashing. Partially covered by Lectures 3 and 4 We’ll do a quick recap of the four sorting algorithms We’ll look at hash tables today Examinable

Syllabus: Binary Trees Binary Trees revisited: implementations by array; expression trees; binary tree implementation of sorted list; access times; algorithms covered include traversal, searching, balancing and deletion. Already covered in Programming Techniques We did state space search and game trees instead Game trees, minimax search and alpha-beta pruning are examinable, the rest is not (because last year’s students didn’t do it) Typical exam question: map out a simple game tree and say what move the computer should make next

Syllabus: Graph Algorithms Graphs revisited: directed and undirected graphs; representations of graphs; basic graph algorithms; applications of graphs to real world problems (for example telecommunications, transportation systems, dependencies between objects). To be covered next week Representation of graphs, Dijkstra’s algorithm Application to the tube map problem Examinable Typical exam question: show application of Dijkstra’s algorithm to a real world problem

Syllabus: NP-Hard Problems Permutations and Combinations: branch and bound; greedy algorithms; backtracking search; typical problems, for example the TSP and related problems, the knapsack problem. Mostly covered by our consideration of state space search and games, and also in Topics 1 and 2 I will touch briefly on this area in my summary and revision lecture in Week 10 Not directly examinable – see the Week 10 lecture for what you need to know in this area

Abstract Data Types Definition: a set of data values and operations on those data values which are precisely specified and independent of any particular implementation Example: a stack makeNewStack() returns an empty stack push(item,stack) puts item onto the top of stack top(stack) returns the top element of stack pop(stack) returns the top item and removes it The external user of the ADT only sees the interface, not the internal workings (representation, algorithms)

Example ADT: Lookup Table I want to create a lookup table to hold the names of my students (keys) and their birthdays (values) Operations: add(key,value) adds a new key-value pair lookup(key) returns the value associated with key delete(key) deletes both key and its value inOrder() show all key-value pairs in order of keys Example: add(“John”, 2nd December) adds John’s birthday lookup(“Fred”) returns Fred’s birthday delete(“Eric”) deletes Eric’s birthday from the table

Lookup Table: Implementation I can implement my lookup table in various ways: which of them is best? Linked list: add new items on to the front of the list, search through the list to perform lookup and deletion, sort the list to show the table in order Binary search tree: add new items to the tree, search the tree to perform lookup and deletion, traverse the tree to show the table in order Hash table: use a ‘magic function’ to map the key onto an integer and store the value at a location in memory directly computable from that integer

Lookup Table: Complexity Exercise: what is the complexity of the lookup table operations for the three implementations given? You can assume the hash function is O(1). Linked ListBinary treeHash table add(key,value) lookup(key) delete(key) inOrder()

Lookup Table: Complexity Exercise: what is the complexity of the lookup table operations for the three implementations given? You can assume the hash function is O(1). Linked ListBinary treeHash table add(key,value)O(1) lookup(key)O(n) delete(key)O(n) inOrder()O(n log n)

Lookup Table: Complexity Exercise: what is the complexity of the lookup table operations for the three implementations given? You can assume the hash function is O(1). Linked ListBinary treeHash table add(key,value)O(1)O(log n) lookup(key)O(n)O(log n) delete(key)O(n)O(log n) inOrder()O(n log n)O(n)

Lookup Table: Complexity Exercise: what is the complexity of the lookup table operations for the three implementations given? You can assume the hash function is O(1). Linked ListBinary treeHash table add(key,value)O(1)O(log n)O(1) lookup(key)O(n)O(log n)O(1) delete(key)O(n)O(log n)O(1) inOrder()O(n log n)O(n)

Lookup Table: Complexity Exercise: what is the complexity of the lookup table operations for the three implementations given? You can assume the hash function is O(1). Linked ListBinary treeHash table add(key,value)O(1)O(log n)O(1) lookup(key)O(n)O(log n)O(1) delete(key)O(n)O(log n)O(1) inOrder()O(n log n)O(n)O(k+n log n)

Lookup Table: Evaluation So which implementation is best? Linked list: simple implementation, efficient only for adding items, works even when no ordering can be defined on the keys Binary search tree: more involved implementation, reasonably efficient in all operations, can iterate over all keys and find a “nearest match” for a given key Hash table: best for adding, lookup and deletion, great for huge data sets, fairly easy to implement, but finding a good hash function can be difficult, iterating over all keys is hard as hash tables don’t preserve ordering