1 / 11

CSE 143 Section AD

CSE 143 Section AD. 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…. Agenda. Queue Examples From Last Time

orinda
Download Presentation

CSE 143 Section AD

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 143 Section AD Quiz Section 16 Jeff West - Quiz Section 16

  2. 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… Jeff West - Quiz Section 16

  3. Agenda • Queue Examples From Last Time • Circle Drawing Example • Efficiency Jeff West - Quiz Section 16

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

  5. 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; } } Jeff West - Quiz Section 16

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

  7. 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… Jeff West - Quiz Section 16

  8. 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(____) Jeff West - Quiz Section 16

  9. 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(____). Jeff West - Quiz Section 16

  10. 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(____). Jeff West - Quiz Section 16

  11. 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? Jeff West - Quiz Section 16

More Related