Midterm review
Midterm’s date: 3/12/08
During class
60 - 100 questions
(true/false and multiple choice)
* bring pencil # 2 and an eraser
Sana.odeh@nyu.edu
1
08/28/08
MAC OS X
– Menus: apple and finder menu
– MAC tools: Clipboard, terminal
– Basic functio
Computer Science 2 Data Structures and Algorithms V22.0102 section 2 Introduction to Trees
Professor: Evan Korth New York University
Road Map
Introduction to trees
Terminology
Binary trees Tree traversal Reading: 4.1 4.2
Tree
Tree defined recursively
Quicksort
http:/math.hws.edu/TMCM/java/xSortLab /
Quicksort I
To sort a[left.right]:
1. if left < right:
2. Terminate
1.1. Partition a[left.right] such that: all a[left.p1] are less than a[p], and all a[p+1.right] are >= a[p] 1.2. Quicksort a[left.p1] 1.
MergeSort
Source: Gibbs & Tamassia
MergeSort
MergeSort
is a divide and conquer method of
sorting
2
MergeSort Algorithm
MergeSort is a recursive sorting procedure that uses at most O(n lg(n) comparisons. To sort an array of n elements, we perform the fo
Computer Science 102 Data Structures and Algorithms V22.0102 Fall 2009 Lecture 1: administrative details
Professor: Evan Korth New York University
1
Road Map for Today
Welcome
Structures Course Description
to Introduction to Data
What material will we c
Java Collections
Professor Evan Korth (adapted from Sun's collections documentation)
APIs and Versions
Number one hint for programming with Java Collections: use the API Be sure to use the 1.5.0 APIs to get the version with generics
http:/java.sun.com/j
Priority Queue (Heap)
A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value (key) of each object (smaller value higher priority, or higher value hig
her priority)
Example Applications:
printer -> print (
Hashing
Text
Read Weiss, 5.1 5.5
Goal
Perform inserts, deletes, and finds in constant average time
Topics
Hash table, hash function, collisions Separate chaining Open addressing: linear probing, quadratic probing, double hashing Load factor
Collision h
Generic types for ArrayList
Old Java (1.4 and older):
ArrayList strings = new ArrayList(); strings.enqueue("hello"); String word = (String) strings.get(0);
New (since 1.5):
ArrayList<String> strings = new ArrayList <String>(); strings.add("hello"); Stri
Final Exam
Thursday, May 6th 4:00 to 5:50 PM in CIWW room 109 (Warren Weaver Hall)
Material Covered
Linked Lists Stacks Queues Trees
Expression Trees Binary Search Tree No AVL trees Heap B-trees
Huffman coding
Material Covered (cont)
Sorts
Selection
Other time considerations
Source: Simon Garrett Modifications by Evan Korth
Disk access time vs CPU time
We have assumed that all instructions are created equally in our analysis all semester. What if this assumption is not true? One example:
It could b
Review: Search
Linear Search Binary Search Search demos:
http:/www.cosc.canterbury.ac.nz/people/mukundan/d
Binary Search Tree
A binary tree where every node's left subtree has values less than the node's value, and every right subtree has values greate
Computer Science 2 Data Structures and Algorithms V22.0102 Intro to "big o" Lists
Professor: Evan Korth New York University
1
Road Map for Today
A
cursory introduction to Big Oh Abstract Data Types Lists
Array implementation Linked Lists
Reading:
Chapt
AVL Trees Data Structures Fall 2008 Evan Korth
Adopted from a presentation by Simon Garrett and the Mark Allen Weiss book
AVL (Adelson-Velskii and Landis) tree
A balanced binary search tree where the height of the two subtrees (children) of a node differ
Tree Searches
Source: David Lee Matuszek
Tree searches
A B D H L M N O E I P F J C G K Q
A tree search starts at the root and explores nodes from there, looking for a goal node (a node that satisfies certain conditions, depending on the problem) For some