Final Exam Review 6 December 2010.

Slides:



Advertisements
Similar presentations
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
Advertisements

Computability Start complexity. Motivation by thinking about sorting. Homework: Finish examples.
Section 8.8 Heapsort.  Merge sort time is O(n log n) but still requires, temporarily, n extra storage locations  Heapsort does not require any additional.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
Merge Sort. What Is Sorting? To arrange a collection of items in some specified order. Numerical order Lexicographical order Input: sequence of numbers.
The Binary Heap. Binary Heap Looks similar to a binary search tree BUT all the values stored in the subtree rooted at a node are greater than or equal.
Priority Queues and Binary Heaps Chapter Trees Some animals are more equal than others A queue is a FIFO data structure the first element.
Greedy algorithms David Kauchak cs161 Summer 2009.
Christopher Moh 2005 Competition Programming Analyzing and Solving problems.
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Kevin Quinn Fall 2015.
Chapter 12 Heaps & HeapSort © John Urrutia 2014, All Rights Reserved1.
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
HEAPS. Review: what are the requirements of the abstract data type: priority queue? Quick removal of item with highest priority (highest or lowest key.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Week 15 – Friday.  What did we talk about last time?  Student questions  Review up to Exam 2  Recursion  Binary trees  Heaps  Tries  B-trees.
DECISION 1. How do you do a Bubble Sort? Bubble Sort:  You compare adjacent items in a list;  If they are in order, leave them.  If they are not in.
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
Sorting and "Big Oh" ASFA AP Computer Science A SortingBigOh.
CSE373: Data Structures & Algorithms Priority Queues
CSE373: Data Structures & Algorithms
Data Structures: Disjoint Sets, Segment Trees, Fenwick Trees
May 3rd – Hashing & Graphs
May 17th – Comparison Sorts
Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008
Midterm Review.
Lesson Objectives Aims Understand the following “standard algorithms”:
Cse 373 May 15th – Iterators.
October 30th – Priority QUeues
The Greedy Method and Text Compression
Quick-Sort 9/12/2018 3:26 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Program based on pointers in C.
December 1st – Graph Madness
Design and Analysis of Algorithms
CMSC 341 Lecture 13 Leftist Heaps
7/23/2009 Many thanks to David Sun for some of the included slides!
Data Structures: Segment Trees, Fenwick Trees
Definition In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) We focus on Deterministic Algorithms Under the.
Dr. David Matuszek Heapsort Dr. David Matuszek
Draw pictures to indicate the subproblems middleMax solves at each level and the resulting maxPtr and PrevPtr for each on this linked list:
i206: Lecture 14: Heaps, Graphs intro.
Lesson Objectives Aims
Unit-2 Divide and Conquer
B-Tree Insertions, Intro to Heaps
Heaps and the Heapsort Heaps and priority queues
Search Related Algorithms
CSE 214 – Computer Science II B-Trees
8/04/2009 Many thanks to David Sun for some of the included slides!
A Robust Data Structure
Merge Sort 1/12/2019 5:31 PM Dynamic Programming Dynamic Programming.
Searching CLRS, Sections 9.1 – 9.3.
CMSC201 Computer Science I for Majors Lecture 25 – Final Exam Review
Sub-Quadratic Sorting Algorithms
Heapsort.
Greedy Algorithms Alexandra Stefan.
Analysis of Algorithms
Sorting.
Quick-Sort 4/25/2019 8:10 AM Quick-Sort     2
Heaps.
Amortized Analysis and Heaps Intro
CSC 380: Design and Analysis of Algorithms
Heapsort.
CO4301 – Advanced Games Development Week 4 Binary Search Trees
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
Heapsort.
OPIM 915 Fall 2010 Data Structures 23-38,
CSCE 3110 Data Structures & Algorithm Analysis
Algorithms CSCI 235, Spring 2019 Lecture 26 Midterm 2 Review
CO 303 Algorithm Analysis and Design
Presentation transcript:

Final Exam Review 6 December 2010

Assignment #5 Will be due tonight @ 11:59 p.m. Take a look at my “Review Notes” if you still have no idea how to approach the problem Stars in cells with no dependencies Runtime issue We will not impose runtime constraints, but you have to use backtracking Be aware that we will do less bug-fixing

Final Exam Information On Monday, 13 December @ 4:00 p.m. – 6:50 p.m. (NOT 4:30 p.m.) You are allowed 3 sheets of letter-sized paper with notes Review Sessions: Tuesday, 7 December @ 1:00 p.m. – 3:00 p.m. in HEC 101 with Remo Wednesday, 8 December @ 1:00 p.m. – 3:00 p.m. in HEC 101 with Chris

Review Question 1 Network Flow Proposed Solution:

Review Question 1 Counter Example: Maximum Flow will be 10 BUT: book is “split up” between boxes x1 and x2

Review Question 2 Edit Distance Remember:

Review Question 3 Backtracking You are given a set of letters, in random order, e.g. “OFCEFI” You have to determine whether or not there exists a way to reorder those letters to form a valid word. Given: A function “startswith(a)”, that determines if there are any words that start with the string “a”

Review Question 3 Backtracking function jumbledLetters(a, b) takes in a set of letters, a, already ordered, and set of letters, b, that needs to be added Base Cases: If startswith(a) == FALSE, return FALSE If b is empty string, return startswith(a) Recursively call jumbledLetters() with next set of letters If any of recursive calls return TRUE, return TRUE If all return FALSE, return FALSE

Review Question 3 Example: Call to jumbledLetters(“OF”, “CEFI”)

Review Question 4 Single Room Scheduling (Lecture 11) Greedy Solution: Sort the requests by finish time. Go through the requests in order of finish time, scheduling them in the room if the room is unoccupied at its start time.

Review Question 4 Show Time Cops 6:30 – 7:30 CSI 7:30 - 8:30 30 Rock 7:00 - 9:00 Office 8:00 - 9:00 Idol 6:00 - 9:15 Survivor 8:45 - 9:45 24 7:30 - 10:30 Law & Order 9:50 - 10:50 SportsCenter 9:15 - 11:00 Show Time Cops 6:30 – 7:30 CSI 7:30 - 8:30 Survivor 8:45 - 9:45 Law & Order 9:50 - 10:50 Maybe ask about how to do Multiple Room Scheduling?

Review Question 5 MakeHeap (Lecture 4) Place all the unsorted elements in a complete binary tree. Going through the nodes in backwards order, and skipping the leaf nodes, run Percolate Down on each of these nodes. If one of the children is less than the node, swap the lowest. Continue until node has only larger (or equal) children or until leaf node

Review Question 5 Initial Heap:

Review Question 5 Final Heap:

Review Question 6  

Review Question 6 Solution:

Review Question 6 Usually a good idea to break down initial equation as much as possible before proceeding

Review Question 7 Code Analysis Matrix Chain Multiplication What problem does this code solve? Symbolically, what does the variable “m” represent? Matrix Chain Multiplication At which matrix you want to split your multiplication a the top level.

Review Question 7 Explain conceptually what is stored in the variables “one”, “two”, and “three”. Is the method “function” efficient? Justify. “one” stores number of multiplications to do the left-side product “two” stores number of multiplications to do the right-side product “three” stores number of multiplications to take the two products from two recursive calls and multiply them No. The exact same recursive call gets made multiple times.

Review Question 8  

Review Question 8  

Review Question 8   Additional Question: Why don’t we just use Bucket Sort for all our sorting? Answer: Because it takes a lot of space and makes the assumption of uniform distribution? Worst-case runtime is still O(N^2). For all practical intents and purposes, QuickSort is the fastest sorting out there.

Review Question 9   Index 1 2 3 4 5 6 7 8 9 Value

Review Question 9 Which row (0 – 9) is this in the path array? Determine the vertices traversed in the shortest path from vertex 3 to vertex 0. From the information given, can we determine which vertex is farthest away from vertex 3? Why or why not? Index 1 2 3 4 5 6 7 8 9 Value 3 3  7  6  2  0 No. Because of insufficient weight info.

Review Question 10 CHEESE!

Good Luck on the Final Exam