Jeff West - Quiz Section 16

Slides:



Advertisements
Similar presentations
Order of complexity. Consider four algorithms 1.The naïve way of adding the numbers up to n 2.The smart way of adding the numbers up to n 3.A binary search.
Advertisements

1 Linked lists Sections 3.2, 3.3, 3.5 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors.
Hold data and provide access to it. Random-access containers: -Allow accessing any element by index -arrays, vectors Sequential containers: -Allow accessing.
Analysis of Algorithms CS Data Structures Section 2.6.
1 Chapter 6 Priority Queues (Heaps) General ideas of priority queues (Insert & DeleteMin) Efficient implementation of priority queue Uses of priority queues.
Searching and Sorting SLA Computer Science 4/16/08 Allison Mishkin.
BST Data Structure A BST node contains: A BST contains
1 Search Algorithms Sequential Search (Linear Search) Binary Search Rizwan Rehman Centre for Computer Studies Dibrugarh University.
CS 46B: Introduction to Data Structures July 30 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
1 CSC 222: Computer Programming II Spring 2004 Pointers and linked lists  human chain analogy  linked lists: adding/deleting/traversing nodes  Node.
SEARCHING (Linear/Binary). Searching Algorithms  method of locating a specific item of information in a larger collection of data.  two popular search.
Big Oh Algorithms are compared to each other by expressing their efficiency in big-oh notation Big O notation is used in Computer Science to describe the.
CS 2430 Day 35. Agenda Introduction to linked lists Bag as linked list Stack as linked list.
SortingBigOh Sorting and "Big Oh" Adapted for ASFA from a presentation by: Barb Ericson Georgia Tech Aug 2007 ASFA AP Computer Science.
SortingBigOh ASFA AP Computer Science A. Big-O refers to the order of an algorithm runtime growth in relation to the number of items I. O(l) - constant.
Introduction to Data Structures and Algorithms
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
329 3/30/98 CSE 143 Searching and Sorting [Sections 12.4, ]
APPLICATIONS OF RECURSION Copyright © 2006 Pearson Addison-Wesley. All rights reserved
Introduction to Classes and Objects Shirley Moore CS 1401 Spring 2013 cs1401spring2013.pbworks.com April 23, 2013.
Sorting and "Big Oh" ASFA AP Computer Science A SortingBigOh.
Pointers and Linked Lists
UMBC CMSC 104 – Section 01, Fall 2016
Pointers and Linked Lists
Data Structures and Algorithms for Information Processing
5.13 Recursion Recursive functions Functions that call themselves
Lecture No.45 Data Structures Dr. Sohail Aslam.
May 17th – Comparison Sorts
CS32 Discussion Section 1B Week 8
Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008
Searching – Linear and Binary Searches
Lecture 14 Searching and Sorting Richard Gesick.
Sequences 6/18/2018 8:51 PM C201: Linked List.
Recitation 13 Searching and Sorting.
Sections 8.7 – 8.8 Balancing a Binary Search Tree.
CPSC 311 Section 502 Analysis of Algorithm
Week 15 – Monday CS221.
RECITATION 1 ANALYSIS OF ALGORITHMS
Search Algorithms Sequential Search (Linear Search) Binary Search
Applications of Recursion
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.
Data Structures 2018 Quiz Answers
CS 177 Week 15 Recitation Slides
Lecture 2: Implementing ADTs
Algorithm design and Analysis
Announcements P2 is due tomorrow Prelim on Monday
Instructor: Lilian de Greef Quarter: Summer 2017
CSE 1342 Programming Concepts
Chapter 9 One-Dimensional Arrays
Lecture 11 Searching and Sorting Richard Gesick.
MSIS 655 Advanced Business Applications Programming
Implementing Hash and AVL
Review & Lab assignments
Analyzing an Algorithm Computing the Order of Magnitude Big O Notation
COMPUTER 2430 Object Oriented Programming and Data Structures I
Jeff West - Quiz Section 15
Jeff West - Quiz Section 4
Jeff West - Quiz Section 8
COMPUTER 2430 Object Oriented Programming and Data Structures I
Jeff West - Quiz Section 9
CS 2430 Object Oriented Programming and Data Structures I
Sorting And Searching CSE116A,B 4/6/2019 B.Ramamurthy.
Revision of C++.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Lecture 4: Introduction to Code Analysis
Lecture 2: Stacks and Queues
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Instructor: Dr. Michael Geiger Spring 2019 Lecture 34: Exam 3 Preview
COMPUTER 2430 Object Oriented Programming and Data Structures I
Data Structures & Programming
Presentation transcript:

Jeff West - Quiz Section 16 CSE 143 Section AD Quiz Section 16 8/9/2001 Jeff West - Quiz Section 16

Jeff West - Quiz Section 16 Announcements Quiz – Stacks, Queues, Efficiency Homework 5 Demo sign-up… Final Review Sessions next Wednesday and Thursday nights – most likely 7pm both nights, location TBA 8 more days until our summer vacation… 8/9/2001 Jeff West - Quiz Section 16

Jeff West - Quiz Section 16 Agenda Queue Examples From Last Time Circle Drawing Example Efficiency 8/9/2001 Jeff West - Quiz Section 16

Jeff West - Quiz Section 16 Copy Constructor FlightQueue::FlightQueue(FlightQueue& other) { front = back = NULL; Node* curOfOther = other.front; while(curOfOther != NULL) { insert(curOfOther -> myFlight); curOfOther = curOfOther -> next; } 8/9/2001 Jeff West - Quiz Section 16

Jeff West - Quiz Section 16 insert void FlightQueue::insert(const Flight& newFlight) { Node* addMe = new Node; addMe -> myFlight = newFlight; addMe -> next = NULL; if(front == NULL) front = back = addMe; else { back -> next = addMe; back = addMe; } 8/9/2001 Jeff West - Quiz Section 16

Circle Drawing Example The circle drawing program is downloadable from the section AD website under today’s date (8/9/2001). 8/9/2001 Jeff West - Quiz Section 16

Jeff West - Quiz Section 16 Efficiency The idea is to get the “big picture”… If you are running some function on an array of N elements, what does the running time look like… Drop the lowest terms and constants to get the “big picture”… Take the worst case… 8/9/2001 Jeff West - Quiz Section 16

Jeff West - Quiz Section 16 Efficiency Examples N3 + 2N + 5 = O(N3) 9N5 + 8N4 + 3N + 17 = O(N5) Heck, what about these ones? N4 + 18N! + 12N3 = O(____) 2N + 12N – 19 = O(____) 8/9/2001 Jeff West - Quiz Section 16

Efficiency of a Nested Loop for(int i = 0; i < size; i++) for(int j = 0; j < 100; j++) for(int k = j; k < size; k++) cout << “Argh, what fun”; Total cost is O(____) + O(____) + O(____) The algorithm grows like O(____). 8/9/2001 Jeff West - Quiz Section 16

Efficiency of Linear Search int Find(int A[], int N, int x) { for(int i = 0; i < N; i++) { if(A[i] == x) return i; return –1; } A linear search like this grows like O(____). 8/9/2001 Jeff West - Quiz Section 16

Efficiency of Binary Search Binary search deals with an array that is guaranteed to be in sorted order. 1 19 27 36 49 57 62 How much extra effort does it take to search if you double the size of the array? How much effort is saved if you halve the size of the array? 8/9/2001 Jeff West - Quiz Section 16