CS 240 Week 2. Introduction to Project 2 Command Line Syntax java Spell word -- source file hard wired into program Run Demo.

Slides:



Advertisements
Similar presentations
Lecture 6 Sept 11, 2008 Goals for the day: Linked list and project # 1 list class in STL (section 3.3) stack – implementation and applications.
Advertisements

1 Todays Objectives Announcements Homework #1 is due next week Return Quiz 1 – answers are posted on the Yahoo discussion page site Basic Java Programming.
Object Oriented Programming with Java
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
CS18000: Problem Solving and Object-Oriented Programming.
CS252: Systems Programming Ninghui Li Program Interview Questions.
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
Boggle Game: Backtracking Algorithm Implementation
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Programming Assignment #4 Binary Trees
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS 146: Data Structures and Algorithms June 18 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
CS 46B: Introduction to Data Structures July 30 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Multiple Choice Solutions True/False a c b e d   T F.
Binary Search Trees. BST Properties Have all properties of binary tree Items in left subtree are smaller than items in any node Items in right subtree.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
MIT AITI 2002 Abstract Classes, Interfaces. Abstract Classes What is an abstract class? An abstract class is a class in which one or more methods is declared,
CS 240 Week 3. List’Em java Grep [-r] directoryName fileSelectionPattern substringSelectionPattern Run Demo java LineCount [-r] directoryName fileSelectionPattern.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Data Structures Week 6: Assignment #2 Problem
Lecture Objectives  To learn how to use a tree to represent a hierarchical organization of information  To learn how to use recursion to process trees.
CompSci Maps  Maps are another way of organizing data  Keys and Values  Each key maps to a value  Some keys can map to the same value  Can.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 02 / 13 / 2009 Instructor: Michael Eckmann.
CPS 506 Comparative Programming Languages Syntax Specification.
Visual C++ Programming: Concepts and Projects Chapter 12B: Linked List (Tutorial)
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Tries Data Structure. Tries  Trie is a special structure to represent sets of character strings.  Can also be used to represent data types that are.
CIS 270—Application Development II Chapter 8—Classes and Objects: A Deeper Look.
CS1101 Group1 Discussion 10 Lek Hsiang Hui comp.nus.edu.sg
COSC 2007 Data Structures II Dr Dave Goforth FA 377 (705) x2316
Compsci 201 Recitation 10 Professor Peck Jimmy Wei 11/1/2013.
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
Classes, Interfaces and Packages
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Symbol tables.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
100e Hosted by vhs © Don Link, Indian Creek School, 2004 Jeopardy.
18-1 Chapter 18 Binary Trees Data Structures and Design in Java © Rick Mercer.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Week 15 – Monday.  What did we talk about last time?  Tries.
Objects and Classes. F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive data type and object type.
Generic Trees—Trie, Compressed Trie, Suffix Trie (with Analysi
CS 240 Week 2.
Tries 07/28/16 11:04 Text Compression
CS240: Advanced Programming Concepts
Data Structures and Design in Java © Rick Mercer
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Agenda Warmup AP Exam Review: Litvin A2
Week 6 - Wednesday CS221.
University of Central Florida COP 3330 Object Oriented Programming
CS230 Tutorial Week 3.
Heaps and Priority Queue
8.1 Tree Terminology and Applications
Lab 10 - Quicksort.
Interface.
An Introduction to Java – Part I, language basics
Ruby Testing 2, 11/9/2004.
Interfaces.
CS240: Advanced Programming Concepts
Chapter 8 Class Inheritance and Interfaces
EE 312 Final Exam Review.
Program: Mini Phone Book 2/11/2016
Presentation transcript:

CS 240 Week 2

Introduction to Project 2 Command Line Syntax java Spell word -- source file hard wired into program Run Demo

Basic Algorithm Look up word in dictionary – Comparison is case insensitive If found List the word Else if a similar word is found List the most similar word Else Indicate no word found See project description for syntax The input word must consist of 1 or more letters

Dictionary Must Be Represented as Trie A tree like structure defined recursively – Root node – Internal nodes (sub-Tries) Leaf nodes have no sub-Tries Each node contains – A count A value > 0 represents the number times a word in the dictionary (represented by a path through the tree to the current node) appears in the dictionary. – 26 Sub-Tries having the values ‘a’..’z’ The Trie (or root of the Trie) contains – The number of words in the dictionary – The number of nodes in the dictionary

Trie Operations Constructor Methods – add(String word) – find(String word); may return null – int getWordCount() – Int getNodeCount()

What Does It Mean for a Word to Be Similar to Another Word Edit Distance – Deletion distance – Transposition distance – Alteration distance – Insertion distance Edit Distance 1 and 2

Making the Output Deterministic One word is “more similar” than another word Based on the following priorities 1.A word that is has an edit distance of one has a higher priority than one that is has an edit distance of 2 2.If both words have the same edit distance then select the one that appears more frequently in the dictionary 3.If two words appear equally often in the dictionary then pick the one the is alphabetically first.

Additional String Operations s.toLowerCase() s.toUpperCase() StringBuilder – Building strings using “+” is expensive – StringBuilder strBuilder = new StringBuilder() strBuilder.append(String) – Can be anything that has a toString method or atomic type strBuilder.delete(int, int) strBuilder.setCharAt(int,char) Code Examples

Interfaces Interaction contract – At any place in a java program you an have variables of the interface type – Object in variables must be instance of an implementing class Keyword “implements” Like.h file in concept (conceptually similar to abstract class) Contains – Constants (static and final) – Method signatures You must provide an implementing class

Interface Example StudentListInterface.java: The interface StudentListInterface.java – ArrayStudentList.java: implements StudentListInterface.java ArrayStudentList.java – ArrayListStudentList.java: implements StudentListInterface.java ArrayListStudentList.java TestingStudentListInterface.java

Interesting Addition of For Loops for(String s = “”; s != null; s = f.readLine()) … Use of finally Example Code – testFile – put in same directory as Example Code testFile