Course Review. Cpt S 223 Fall 2010

Similar documents
Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Course Review. Cpt S 223 Fall 2009

Course Review for Finals. Cpt S 223 Fall 2008

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Cpt S 223 Course Overview. Cpt S 223, Fall 2007 Copyright: Washington State University

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

The questions will be short answer, similar to the problems you have done on the homework

Data Structures and Algorithm Analysis in C++

AP Computer Science 4325

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

CS301 - Data Structures Glossary By

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

UNIT III BALANCED SEARCH TREES AND INDEXING

Data Structures Question Bank Multiple Choice

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

Union-Find: A Data Structure for Disjoint Set Operations

ECE250: Algorithms and Data Structures Midterm Review

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

CSCI-1200 Data Structures Fall 2018 Lecture 23 Priority Queues II

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

Priority Queues Heaps Heapsort

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Chapter 6 Heaps. Introduction. Heap Model. Heap Implementation

Basic Data Structures (Version 7) Name:

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

) $ f ( n) " %( g( n)

Heap Model. specialized queue required heap (priority queue) provides at least

Analysis of Algorithms

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University

Data Structure. IBPS SO (IT- Officer) Exam 2017

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Union-Find: A Data Structure for Disjoint Set Operations

Table of Contents. Chapter 1: Introduction to Data Structures... 1

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

Binary Trees, Binary Search Trees

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

CS8391-DATA STRUCTURES

Advanced Set Representation Methods

Computer Science 1 Study Union Practice Problems. What are the arguments to malloc? calloc? realloc? What do they do?

CSE 373 Sample Midterm #2 (closed book, closed notes, calculators o.k.)

CS 8391 DATA STRUCTURES

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

CSE373: Data Structures & Algorithms Lecture 9: Priority Queues and Binary Heaps. Linda Shapiro Spring 2016

Trees. (Trees) Data Structures and Programming Spring / 28

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

INSTITUTE OF AERONAUTICAL ENGINEERING

CS350: Data Structures Heaps and Priority Queues

CSCI2100B Data Structures Heaps

Practice Midterm Exam Solutions

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

CSE 373 Autumn 2012: Midterm #2 (closed book, closed notes, NO calculators allowed)

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

Final Examination CSE 100 UCSD (Practice)

CSci 231 Final Review

Tree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)

CMSC 341 Priority Queues & Heaps. Based on slides from previous iterations of this course

Summer Final Exam Review Session August 5, 2009

COMP : Trees. COMP20012 Trees 219

Programming II (CS300)

Lecture 6: Analysis of Algorithms (CS )

Analysis of Algorithms

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Programming II (CS300)

n 2 ( ) ( ) + n is in Θ n logn

CSE373: Data Structures & Algorithms Lecture 9: Priority Queues. Aaron Bauer Winter 2014

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Binary Trees

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

3. Priority Queues. ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority.

Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

Department of Computer Science and Technology

Data Structures Lesson 9

CS302 Data Structures using C++

CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, Problem Topic Points Possible Points Earned Grader

Priority Queues Heaps Heapsort

DATA STRUCTURES AND ALGORITHMS

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

List of Transparencies

Recall: Properties of B-Trees

Final Exam. EECS 2011 Prof. J. Elder - 1 -

Lecture: Analysis of Algorithms (CS )

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Transcription:

Course Review Cpt S 223 Fall 2010 1

Final Exam When: Thursday (12/16) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program assignments Weiss book 2

Course Overview What are abstract data types? How to design data structures for different purposes? How to use data structures? How to measure how good they are? How to pick the right data structure(s) while designing algorithms? 3

Data structures covered Maintain a set of elements Simple linear structures FIFO, LIFO Searching (ordered) Searching (unordered), string=>int mapping Prioritizing Disjoint set operations Network, interactions Sorting algorithms String data structures Spatial data structures Linked list, array Queue, stack BST, AVL tree, B-tree (for disks) Hash table Binary heap, binomial heap Union-find Graphs Insertion, quick sort, merge sort, heap sort, etc. PATRICIA tree, suffix tree Quad-tree (2D), Oct-tree (3D), k-d trees 4

User Developmental Cycle Problem specification (ideas) High-level design Data Structures (garage tools) input Experimentation - Simulations - real data - benchmarking (testing) refine Algorithm design (methods) - optimize costs - maximize performance - space-time tradeoffs - design simplicity Analysis 5

Course Review Program design Tradeoffs: space, time efficiency, design simplicity Runtime measurement, plotting and explanation STL: vector, list, queue, stack set, map, multiset, multimap priority_queue hash_set, hash_map Standard: Union-find 6

Objectives 1. Introduce new & advanced data structures 2. Introduce algorithmic design and analysis 3. Solve problems using different data structures and design techniques, and compare their performance and tradeoffs 4. Implement algorithms and data structures in C++ 7

Math Review Series: Definitions, manipulations, arithmetic and geometric series closed form Proofs: Know definition, components, and how to use the following Proof by induction Proof by counterexample Proof by contradiction Recursion Know definition and rules Analyze running time of recursive algorithm Tail recursion 8

Algorithmic Analysis Why analyze an algorithm? Line-by-line analysis Input: Best-case, worst-case and average-case analysis Problem: Upper bound, lower bound Rate of growth for algorithms: Definitions and notation (O, Ω, Θ, o, w) 9

Abstract Data Types Lists Operations: Insert, Delete, Search Implementations: vectors, singly-linked lists, double-linked lists, sentinels Analysis of operations for each implementation Stacks (LIFO) Operations: Push, Pop, Top Implementations: linked-list, vector Analysis of operations for each implementation Queues (FIFO) Operations: Enqueue, dequeue Implementations: linked-list, vector Analysis of operations for each implementation Standard Template Library (STL) Use of vector, list, stack and queue template classes Use of iterators Know all the tradeoffs (in time & space) between all these data structures 10

Trees (in memory) Definitions: root, leaf, child, parent, ancestor, descendant, path, height, depth Binary tree: Definition, traversals Storing/representation: All children: use array or list Store pointers to only Leftmost child and right sibling Other representations possible Tree traversals Inorder, postorder and preorder 11

Search Trees Binary search tree (BST) Definition Operations: Insert, Delete, Search, FindMin, FindMax, traversals Know how to perform these on a BST and show resulting BST Know worst-case and average-case analysis of performance Balanced BST (AVL trees) Definition Operations: Rotations & Cases, Insert, Lazy Delete, Search, FindMin, FindMax Know how to perform these on an AVL tree and show resulting AVL tree Know worst-case performance STL set and map classes Differences How to use them 12

Disk-based Search Trees B-trees Definition and properties Input parameters: B, D, K M and L, and how to choose them Operations: Insert, Delete, Search Know how to perform these on a B-tree and show resulting B-tree Know worst-case performance Know how to calculate height of a B-tree 13

Priority Queues Binary heap, Binomial heaps Need to know: Binary heap Structure property: complete binary tree except the last level (filled breadth-first left to right) Heap order property Min heap : each node s value is less than or equal to its children Binomial heap Structure property: A forest of binomial trees (similar to binary representation) Heap order property: Min heap: within each binomial tree, same heap order like in binary heap 14

Implementation: Need to know Binary heap How to convert tree representation to array and vice versa When to use percolateup and percolatedown Computation complexities of all basic heap operations on binary heap Insert, buildheap, deletemin Binomial heap Array of pointers to each binomial tree log n binomial tree pointers Know relationships between binomial heap, binomial trees and their properties Computation complexities of all basic heap operations on binary heap Insert, deletemin, merge 15

Run-times for each heap operation Insert DeleteMin Merge Binary heap O(lg n) worst-case, O(1) amortized using buildheap O(lg n) O(n) Binomial Heap O(lg n) worst-case O(lg n) O(lg n) O(1) amortized (or equivalently, O(m) for m successive calls to insert) 16

Other heap operations deletemax decreasekey increasekey remove Need to know all the complexities and be ready to write pseudocodes for the above Also be prepared to think of writing basic application code that use heap functionalities 17

Union-Find data structure Union-find Supports two operations on disjoint sets: Union(a,b) Find(a) One application is equivalence class computation: Maximal subsets defined by equivalence relation Disjoint subsets Array implementation 18

Example application: Equivalence class computation Steps in Union(x,y): 1. EqClass x = Find (x) 2. EqClass y = Find (y) 3. EqClass xy = UnionSets (EqClass x, EqClass y ) Equivalence class algorithm: Initially, put each element in a set of its own FOR EACH element pair (a,b): Check [a R b = true] IF a R b THEN Union(a,b) 19

Variations in Union Simple Union (aka Arbitrary Union) Perform arbitrary linking of roots Smart Unions 1. Union-by-Rank (aka. union-by-height) Connect shorter tree under taller tree 2. Union-by-Size Connect smaller size tree under larger size tree (size(tree) = #nodes in the tree) Remember: union always calls find internally 20

Variations of Find Simple Find Simply returns the root id without modifying the tree Smart Find Uses path compression Link all nodes along the path from x to the root directly to the root Returns the root id, but the resulting tree could have been modified as a result of path compression 21

Heuristics & their Gains Simple Union, Simple Find Union-by-size, Simple Find Union-by-rank, Simple Find Arbitrary Union, Path compression Find Union-by-rank, Path compression Find This is the default version of the union-find data structure Worst-case run-time for m operations O(m n) O(m log n) O(m log n) O(m log n) Extremely slow Growing function O(m Inv.Ackermann(m,n)) = O(m log*n) 22

Hashing Hash functions purpose: string to integer, integer to integer Choice of a good hash functions Reduce chance of collision Relatively smaller key value Does not need huge hash table size Hash Tables use hash functions Hash table size should be a prime Load factor Measure to tell how crowded a hash table is Know algorithms & analysis for the following Collision resolution by chaining Collision resolution by open-addressing Linear probing, quadratic probing Double hashing Rehashing Think of applications where hash tables could work out better than other data structures. 23

Sorting Be familiar with the algorithms and the various complexities (worst,best,avg) for: Insertion sort, bubble sort Merge sort Quick sort lower bound for the sorting problem using decision tree Integer sort: Counting sort Bucket sort Radix sort 24

Graphs Definitions Simple graph, directed graph, weighted graph Path, cycle Need to know: Representation as adjacency matrix and adjacency list Shortest path problems: Algorithms and running times 25

Specialized data structures String data structures PATRICIA tree Suffix tree Spatial data structures Domain decomposition technique Quad-tree (for 2D data) Oct-tree (for 3D data) Other trees: k-d tree, R-tree, etc. 26

General Tips Work out examples of basic operations Show steps to convey your thought process Think from the perspective of the grader when writing solutions Questions mostly objective, but be prepared to see one or two subjective ones too Write less and to the point Don t leave questions unanswered If unable to solve, write at least your approach idea(s) I do give partial credits GOOD LUCK! 27

Thank You & Good Luck! COURSE EVALUATIONS!! http://skylight.wsu.edu/s/60faae97-fb67-41c6-91e3-1466918cae31.srv 28