Midterm Review CSE 2011 Winter 2011 113 October 2015.

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

Chapter 1: INTRODUCTION TO DATA STRUCTURE
Binary Trees Chapter 6. Linked Lists Suck By now you realize that the title to this slide is true… By now you realize that the title to this slide is.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
CS50 SECTION: WEEK 3 Kenny Yu. Announcements  Watch Problem Set 3’s walkthrough online if you are having trouble.  Problem Set 1’s feedback have been.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 24 Sorting.
CS 171: Introduction to Computer Science II
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
Chapter 19: Searching and Sorting Algorithms
CSE332: Data Abstractions Lecture 9: B Trees Dan Grossman Spring 2010.
1 Assignment 2: (Due at 10:30 a.m on Friday of Week 10) Question 1 (Given in Tutorial 5) Question 2 (Given in Tutorial 7) If you do Question 1 only, you.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L12 (Chapter 20) Lists, Stacks,
Unit 11a 1 Unit 11: Data Structures & Complexity H We discuss in this unit Graphs and trees Binary search trees Hashing functions Recursive sorting: quicksort,
Marc Smith and Jim Ten Eyck
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Version TCSS 342, Winter 2006 Lecture Notes Trees Binary Trees Binary Search Trees.
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.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
Trees Chapter 8. 2 Tree Terminology A tree consists of a collection of elements or nodes, organized hierarchically. The node at the top of a tree is called.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
Review – Part 1 CSE 2011 Winter September 2015.
Recursion Bryce Boe 2013/11/18 CS24, Fall Outline Wednesday Recap Lab 7 Iterative Solution Recursion Binary Tree Traversals Lab 7 Recursive Solution.
CS 3610 Midterm Review.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
© 2011 Pearson Addison-Wesley. All rights reserved 11 B-1 Chapter 11 (continued) Trees.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
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,
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
Trees Chapter 8. 2 Tree Terminology A tree consists of a collection of elements or nodes, organized hierarchically. The node at the top of a tree is called.
Outline Binary Trees Binary Search Tree Treaps. Binary Trees The empty set (null) is a binary tree A single node is a binary tree A node has a left child.
Recursive Data Structures and Grammars  Themes  Recursive Description of Data Structures  Grammars and Parsing  Recursive Definitions of Properties.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
Priority Queues and Heaps. October 2004John Edgar2  A queue should implement at least the first two of these operations:  insert – insert item at the.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Week 7 - Friday.  What did we talk about last time?  Trees in general  Binary search trees.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 25 Trees, Iterators,
CSE205 Review Session SAMUEL & JESSA. Recursion WHAT IS RECURSION?  Recursion is a tool a programmer can use to invoke a function call on itself. 
Course Review Fundamental Structures of Computer Science Margaret Reid-Miller 29 April 2004.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
CS 146: Data Structures and Algorithms June 30 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Course Info Instructor U.T. Nguyen Office: CSEB Office hours: Tuesday, 14:30-15:30 Thursday, 12:00-12:45 By.
Binary Tree Implementation. Binary Search Trees (BST) Nodes in Left subtree has smaller values Nodes in right subtree has bigger values.
1 Joe Meehean. A A B B D D I I C C E E X X A A B B D D I I C C E E X X  Terminology each circle is a node pointers are edges topmost node is the root.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Symbol tables.
23 February Recursion and Logarithms CSE 2011 Winter 2011.
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
DATA STRUCURES II CSC QUIZ 1. What is Data Structure ? 2. Mention the classifications of data structure giving example of each. 3. Briefly explain.
Final Exam Review COP4530.
Final Exam Review CS 3358.
Midterm Review.
Week 6 - Wednesday CS221.
COMP 103 Binary Search Trees.
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.
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.
CSE 326: Data Structures: Midterm Review
Chapter 2: Getting Started
Final Exam Review COP4530.
EE 312 Software Design and Implementation I
EE 312 Final Exam Review.
EE 312 Software Design and Implementation I
Presentation transcript:

Midterm Review CSE 2011 Winter October 2015

Algorithm Analysis Given an algorithm, compute its running time in terms of O, , and  (if any).  Usually the big-Oh running time is enough. Given f(n) = 5n + 10, show that f(n) is O(n).  Find c and n 0 Compare the grow rates of 2 functions. Order the grow rates of several functions.  Use slide 14.  Use L’Hôpital’s rule. 2

Running Times of Loops Nested for loops: If the exact number of iterations of each loop is known, multiply the numbers of iterations of the loops. If the exact number of iterations of some loop is not known, “open” the loops and count the total number of iterations. 3

Running Time of Recursive Methods Could be just a hidden “for" or “while” loop.  See “Tail Recursion” slide.  “Unravel” the hidden loop to count the number of iterations. Logarithmic  Examples: binary search, exponentiation, GCD Solving a recurrence  Example: merge sort, quick sort 4

Recursion Know how to write recursive functions/methods: Recursive call  Adjusting recursive parameter(s) for each call Base case(s) 1.Use the definition (factorial, tree depth, height) 2.Cut the problem size by half (binary search), or by k elements at a time (sum, reversing arrays). 3.Divide and conquer (merge sort, quick sort) 5

Sorting Algorithms Insertion sort Merge sort Quick sort Lower bound of sorting algorithms  O(NlogN) When to use which sorting algorithm? Linear-time sorting (bucket sort) 6

Running Time of Tree Methods Most tree methods are recursive. Visualize the recursion trace. Count the number of nodes that were visited (processed) k. Compute the running time for processing each node O(m). If O(m v ) ≠ O(m u ), sum up the running times of the k nodes. Otherwise total running time = k  O(m) 7

Arrays and Linked Lists Arrays A = B Cloning arrays Extendable arrays Strategies for extending arrays:  doubling the size  increment by k cells Linked lists Singly linked Doubly linked Implementation Running times for insertion and deletion at the two ends. 8

Running Times of Array and Linked List Operations Operation Array unsorted Array sorted DL list unsorted DL list sorted insertO( ) deleteO( ) searchO( ) 9

Stacks, Queues and Deques Operations Array implementation Linked list implementation Running times for each implementation Assignment 3 (deques) 10

Trees Definitions, terminologies Traversal algorithms and applications  Preorder  Postorder Computing depth and height of a tree or node. 11

Binary Trees Linked structure implementation Array implementation Traversal algorithms  Preorder  Postorder  Inorder Properties: relationships between n, i, e, h. 12

Binary Search Trees Properties Searching Insertion  Distinct keys  Duplicate keys Deletion Running times 13

During Reading Week Office hours: Friday, 25 February, 11:30-13:00 CSEB-2024 Homework (trees) R-7.5, 7.6, 7.7, 7.16, 7.23 C-7.4, 7.5, 7.6, 7.9 (C-7.23, 7.33, 7.34: optional, more difficult) R-10.1, 10.3, 10.4 Implement BST insertion method using the posted binary tree Java template. 14

Midterm Test Date: Tuesday, March 1 Time: 13:00-14:20 (80 minutes) Location: CB-121 (lecture room) Materials  Lectures notes from the beginning up to and including the lecture on February 17.  Corresponding sections in the textbook.  Assignments 1, 2 and 3. 15

Test Rules This is a closed-book test. No books, notes or calculators are allowed. You will be given blank paper for scrap work. Bring a photo ID, pens, and pencils. You may use pencils with darkness of at least HB; 2B is preferred. No questions are allowed during the test. You may leave the classroom if you hand in your test booklet 15 minutes or more before the test ends. Programming problems will be marked based on both correctness and efficiency. You may use either Java or Java-like pseudo-code. 16

Test Rules (2) Be present at 12:55 P.M. Put away all notes and books (under the seats). Seating:  4 students per table (or 8 per row), except the first row.  6 students in the first row (or 3 per table). Remind your neighbour(s) to put away all notes and books and follow the seating rule.