First programming project: Key-Word indexer



Similar documents
6.080 / Great Ideas in Theoretical Computer Science Spring 2008

COMP 112 Assignment 1: HTTP Servers

COMPSCI 105 S2 C - Assignment 2 Due date: Friday, 23 rd October 7pm

Symbol Tables. Introduction

Introduction to Programming System Design. CSCI 455x (4 Units)

CS 301 Course Information

CS 300 Data Structures Syllabus - Fall 2014

Algorithm Design and Analysis Homework #1 Due: 5pm, Friday, October 4, 2013 TA === Homework submission instructions ===

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Turing Machines, Part I

CMSC 152: Introduction to Computer Science II

Dynamic Programming Problem Set Partial Solution CMPSC 465

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Sources: On the Web: Slides will be available on:

In-Memory Database: Query Optimisation. S S Kausik ( ) Aamod Kore ( ) Mehul Goyal ( ) Nisheeth Lahoti ( )

CMSC Fundamentals of Computer Programming II (C++)

Parallel and Distributed Computing Programming Assignment 1

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

csce4313 Programming Languages Scanner (pass/fail)

An Incomplete C++ Primer. University of Wyoming MA 5310

Forming a P2P System In order to form a P2P system, the 'central-server' should be created by the following command.

Programming Languages

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

02-201: Programming for Scientists

Lecture 5 - CPA security, Pseudorandom functions

Please consult the Department of Engineering about the Computer Engineering Emphasis.

Web Document Clustering

Lab 2: Swat ATM (Machine (Machine))

Reading 13 : Finite State Automata and Regular Expressions

This is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.

CS423 Spring 2015 MP4: Dynamic Load Balancer Due April 27 th at 9:00 am 2015

6.080/6.089 GITCS Feb 12, Lecture 3

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

How To Teach C++ Data Structure Programming

Writing an essay. This seems obvious - but it is surprising how many people don't really do this.

Fundamentals of Computer Programming CS 101 (3 Units)

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Curriculum Map. Discipline: Computer Science Course: C++

Data Structures and Data Manipulation

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

Lab 5: BitTorrent Client Implementation

TA: Matt Tong Tues EBU3b B225 - Office hour WLH Discussion Thurs EBU3b B250/B250A - Lab/Office hour

A. Aiken & K. Olukotun PA3

Informatica e Sistemi in Tempo Reale

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

10CS35: Data Structures Using C

CS A250 (CRN ) C++ Programming Language 2. Syllabus Fall 2015

University of Dayton Department of Computer Science Undergraduate Programs Assessment Plan DRAFT September 14, 2011

FOPR-I1O23 - Fundamentals of Programming

CS107L Handout 04 Autumn 2007 October 19, 2007 Custom STL-Like Containers and Iterators

CSCI 1301: Introduction to Computing and Programming Summer 2015 Project 1: Credit Card Pay Off

Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Introduction to SQL for Data Scientists

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

TECHNICAL UNIVERSITY OF CRETE DATA STRUCTURES FILE STRUCTURES

Department of Electrical and Computer Engineering. EEL 3160 Embedded C++ and Data Structures. Tuesday & Thursday 3:00 5:00 pm

Project 2: Bejeweled

Illinois Institute of Technology Stuart School of Business Course Syllabus Fall Instructor Information. Course Information

Hypercosm. Studio.

Compiler I: Syntax Analysis Human Thought

Ordered Lists and Binary Trees

CS 1301 Homework 6 Scribbler Line Sensing Due: Friday March 13th, before 11:55pm PM EST. Out of 130 points Files to submit:

Lab assignment #2 IPSec and VPN Tunnels (Document version 1.1)

Binary Heap Algorithms

Lecture 12 Doubly Linked Lists (with Recursion)

CSE 326: Data Structures B-Trees and B+ Trees

How to Avoid an Attack - Security Testing as Part of Your Software Testing Process

CMPSCI611: Approximating MAX-CUT Lecture 20

Hadoop Parallel Data Processing

Introduction to formal semantics -

Training for Clarendon College Faculty

LINKED DATA STRUCTURES

Introduction to Theory of Computation

Software Engineering Concepts: Testing. Pointers & Dynamic Allocation. CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009

Intro to Databases. ACM Webmonkeys 2011

Comp151. Definitions & Declarations

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

CS 103 Lab Linux and Virtual Machines

New York University Computer Science Department Courant Institute of Mathematical Sciences

Software Engineering and Service Design: courses in ITMO University

EE360: Digital Design I Course Syllabus

Computer Science CS 2334: Programming structures and abstractions

CS/COE

Course Syllabus DISS 720 Human Computer Interaction (720 4 credits) Fall Term 2009, August 24 December 13, 2009

Grade 6 English Language Arts Performance Level Descriptors

SCIENCE PROJECT PAGE 1

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

The Relational Data Model

Transcription:

University of Illinois at Chicago CS 202: Data Structures and Discrete Mathematics II Handout 2 Professor Robert H. Sloan Friday, August 30, 2002 First programming project: Key-Word indexer 1 Indexing books by key words For this assignment, you will create a keyword reference index and answer queries from this index. Each query will be a keyword (e.g., Congress ) or keyword phrase (e.g., pathological liars ). The program should return the the bibliographic reference of every work (if any) which has that keyword/keyword phrase. The program will need to be able to add and delete bibliographic references, answer queries, and print out either the list of keywords or the list of books in alphabetical order (by author in the case of books). Your program will take a single command-line argument, which will give the name of an input file. Your program will write output to the terminal. You must use turnin and provide us with a makefile. Your makefile can specify either the CC or the g++ compiler. The input file will contain the following commands: ADD n Read the following line, which contains a bibliographic reference in the format (title; author; year) and the n lines after that, each of which is a keyword for that reference. The keywords should be added to the table of keywords (stored in a binary search tree) if they aren t already there. Also, you ll want somehow to remember that the keyword refers to this reference. Note that bibliographic references and keyword phrases may be arbitrarily long. You will have no difficulties with this as long as you use the standard C++ type string and avoid the C type char*. Read the next line, which contains a keyword, and print out the bibliographic reference(s), if any, for it. If there are no such references, print a message saying so. LIST Print out all the keywords in the table in alphabetical order. BOOKS Print out all the references in alphabetical order. DELETE Read the next line, and delete the work with that author. QUIT End the program.

2 Handout 2: First programming project: Key-Word indexer 2 Data structures Both the keywords and the book data should be stored in binary search trees. You should build your own binary search tree class, because as explained in the next paragraph, you will need some special data members that are not in most binary search tree classes. You may use the class from the text, or some other source as a starting point if you wish. If you do this, please document in your comments that you based your work on some existing class and cite a source (either a book or a URL. You should have only one binary search tree class. In order to save storage space, we will have only one entry per book or keyword in each tree, no matter how many keywords reference a given book or vice versa. Therefore, each element in the tree of keywords will contain a linked list of ref-pointer nodes (or a pointer to the linked list if you think that s better design.) (Note that in this linked list, the data field will contain a pointer.) Each ref-pointer will point to the appropriate element in the tree storing bibliographic references. This allows many keywords to point to the same bibliographic reference. (In a real world system, bibliographic references might be much longer than keywords.) Similarly, the entries for books will contain a pointer to a linked list of pointers to keyword elements. (You ll need this information when you delete a book.) 2.1 Using standard String and List classes You are encouraged to use the STL linked list class; you are not required to do so. (However, I would be giving slightly more time for this assignment were I not relying on the fact that you can use the linked list class and the string class.) Here are a few quick examples of using the STL list class. For this example, I am assuming a list of char s. #include <list> list<char> mylist; list<char>::iterator currentpos; currentpos = mylist.begin(); mylist.insert(currentpos, o ); mylist.insert(currentpos, f ); // List is now f, o The iterator can be moved forward or backward using ++ and --. The iterator s begin() method gives the position of the front of the list; its end() method gives a position immediately after the end of the list. The list class has a method erase whose argument is an iterator that gives the position at which to delete a list element.

Handout 2: First programming project: Key-Word indexer 3 2.2 Miscellaneous program requirements You must not leak memory. That is, when an item is deleted, you need to be careful to free all of its binary tree node, and anything else you may have allocated d dynamically with new. (Which may not be anything else if you use the STL String and List classes, depending on implantation choices you make.) 2.3 Documentation For this program, 65% of the grade will depend on correct functionality. The remaining 35% will be based on a correctly functioning makefile, adherence to the course coding standards, and general design quality.

4 Handout 2: First programming project: Key-Word indexer Here is some sample input. We probably won t use this particular input file for grading; it s just an example. ADD 7 Godel, Escher, Bach; Hofstader; 1980 undecidability knowledge fugues puzzles art music ADD 2 Prince of the Blood; Feist; 1989 fantasy adventure puzzles ADD 4 Computational Learning Theory: New Models and Algorithms; Sloan; 1989 machine learning concept learning noise neurons LIST DELETE Feist BOOKS QUIT

Handout 2: First programming project: Key-Word indexer 5 3 Submission Deadline: Your code must be electronically submitted using the turnin program on the departmental machines by 10 p.m. Thursday, September 12. You must provide us with a working makefile. Partial credit for unfinished work (that compiles!) will be given; no credit will be given for late work.