King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Similar documents
King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017

Computer Science 1 Program 4 TA Lab (Stacks & Queues) Assigned: 3/2/11 Due: 3/23/11 (Wednesday) at 11:55pm (WebCourses time)

Jawwal System (Linked Lists)

CS 455 Midterm 2 Spring 2018 [Bono] Apr. 3, 2018

Lab Exercise 6: Abstract Classes and Interfaces CS 2334

Programming Assignment 2 ( 100 Points )

Lab Assignment. Lab 1, Part 2: Experimental Evaluation of Algorithms. Assignment Preparation. The Task

Programming Assignment HW4: CPU Scheduling v03/17/19 6 PM Deadline March 28th, 2019, 8 PM. Late deadline with penalty March 29th, 2019, 8 PM

UNIVERSITY OF MASSACHUSETTS LOWELL Department of Electrical and Computer Engineering. Program 8 EECE.3220 Data Structures Fall 2017

Homework Assignment #3

Programming Assignment HW5: CPU Scheduling draft v04/02/18 4 PM Deadline April 7th, 2018, 5 PM. Late deadline with penalty April 9th, 2018, 5 PM

Templates and Operator Overloading in C++

Project 4: Implementing Malloc Introduction & Problem statement

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

CS 2604 Minor Project 1 DRAFT Fall 2000

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

The Program Specification:

Introduction to Programming II Winter, 2015 Assignment 5 (Saturday, April 4, 2015: 23:59:59)

CS 2704 Project 3 Spring 2000

The Big Picture. Linker. Module 1. Module 2. One Module. Module 3. Module 4

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

Project #3. Computer Science 2334 Fall Create a Graphical User Interface and import/export software for a Hurricane Database.

CS348 FS Solving NP-Complete Light Up Puzzle

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

UNIVERSITY OF MASSACHUSETTS LOWELL Department of Electrical and Computer Engineering. Program 10 EECE.3220 Data Structures Fall 2017.

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

ASSIGNMENT TWO: PHONE BOOK

************ THIS PROGRAM IS NOT ELIGIBLE FOR LATE SUBMISSION. ALL SUBMISSIONS MUST BE RECEIVED BY THE DUE DATE/TIME INDICATED ABOVE HERE

be able to read, understand, and modify a program written by someone else utilize the Java Swing classes to implement a GUI

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

EECE.2160: ECE Application Programming

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

CS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic

Text Generator Due Sunday, September 17, 2017

CSE 373: Homework 1. Queues and Testing Due: April 5th, 11:59 PM to Canvas

CMPSCI 187 / Spring 2015 Sorting Kata

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

Decision Logic: if, if else, switch, Boolean conditions and variables

CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 4

Spring 2017 CMSC 140 Programming Project 7: Payroll

1. Introduction. 2. Deliverables

Lab 4 - Lazy Deletion in BSTs

PIC 10B Lecture 1 Winter 2014 Homework Assignment #2

Learning objectives. Reading carefully. Managing your time. CS2110 Fall 2017 Assignment A1. PhD Genealogy. See CMS for the due date

Lab Exercise 4: Inheritance and Polymorphism CS 2334

Assignment 5: MyString COP3330 Fall 2017

Final Programming Project

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Computer Science Foundation Exam

Practical 2: Ray Tracing

Tips from the experts: How to waste a lot of time on this assignment

PA3: Violet's Vending Venture (Version 3.0)

UNIVERSITY OF MASSACHUSETTS LOWELL Department of Electrical and Computer Engineering. Program 9 EECE.3220 Data Structures Fall 2017

EECE.2160: ECE Application Programming Spring 2017

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

Lab 1 Implementing a Simon Says Game

CS 241 Data Organization using C

CS 241 Data Organization. August 21, 2018

EECE.2160: ECE Application Programming Spring 2019

CSE100 Principles of Programming with C++

Computer Science II Data Structures

Programming Assignment - 1

Project 5 Handling Bit Arrays and Pointers in C

Project 1. due date Sunday July 8, 2018, 12:00 noon

Assignment Tutorial.

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

Assignment 4. Overview. Prof. Stewart Weiss. CSci 335 Software Design and Analysis III Assignment 4

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa)

COP 3014 Honors: Spring 2017 Homework 5

Programming Assignment 2

CS5401 FS Solving NP-Complete Light Up Puzzle

CMPSCI 187 / Spring 2015 Hanoi

A Computational System for Polynomials with Two Variables

EECE.2160: ECE Application Programming

CS2102, D15 Exam 1. Name:

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

Computer Science II CSci 1200 Sections 6-10 Week 3, Monday Lecture January 28, 2002 Functions, Structs and Multiple Files

CIS 121 Data Structures and Algorithms with Java Spring 2018

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA === Homework submission instructions ===

CMSC 201 Fall 2016 Homework 6 Functions

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

CSE 143 Final Part 1, August 18, 2011 Sample Solution

Installing and Using Dev-C++

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm)

Computer Engineering Department COM 102 OBJECT ORIENTED PROGRAMMING POSTLAB #5

CS 202, Fall 2017 Homework #3 Heaps and AVL Trees

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

Lab 1 Implementing a Simon Says Game

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

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

CIS 2168: Assignment #9

CS 1044 Program 2 Spring 2002

Transcription:

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department CPCS204, 2 nd Term 2014 Program 5: FCITbook Assigned: Thursday, May 1 st, 2014 Due: Thursday, May 15 th, 2014 by 11:55PM Purpose: 1. Practice using Binary Search Trees. Read Carefully: The deadline for this project is 11:55 PM on Thursday May 15 th, 2014. This program is worth 4% of your final grade. WARNING: This is an individual project; you must solve it by yourself. Any form of cheating will result in receiving - 4 (less than zero) in the project. WARNING: Late submission will not be accepted. Any project submitted after the cutoff time will receive zero. Email Submission: This project must be submitted online via Email to: cpcs.204@hotmail.com The subject line of your email message should be as the following form: SectionNumber_StudentID_ProjectNumber Example: EA_ 1110348_ P5 The source file(s) of your program should be zipped up. You must name the zip file using the following naming convention: SectionNumber_StudentID_ProjectNumber.zip Example: EA_ 1110348_ P5.zip Discussions: We will randomly select a certain number of students for discussion for each project. If you are chosen for discussion, we will email you with a time. If you do not show up for discussion, you will get a zero for the program.

Program 5: FCITbook Objective Learn to implement binary search trees and to combine that functionality with linked lists. The Problem After working hard at Program 4, you feel confident enough to do anything! You decide to create a database manager for a new FCIT social networking site, www.fcitbook.com. Your database should be able to store unlimited number of students (users) along with their basic personal information (ID, first name, last name, age, department, etc.). Additionally, each user should be able to maintain a list of all his FCIT friends. So how do you implement this? You know that you must search the database quickly based on their name or ID. And with your extensive knowledge of data structures and Big O running times, you know that a simple array of users or a linked list of users would be an EPIC FAIL, as this would result in an O(n) search. Therefore, you realize that the best way, based on your CPCS-204 knowledge, is to implement this as a binary search tree. Searching, insertion, and deletion should all take approximately O(logn), which is MUCH faster. You will store users in FCITbook based on their student ID numbers, and it will be guaranteed that this ordering of students (by ID) will be the exact same as the alphabetical ordering by last name and then first name. So Bob Smith is guaranteed to have a smaller ID than Joe Smith, because his first name is smaller than Joe. What is the benefit of this? This means that you do not need to insert into the BST by names. Instead, you can just insert by ID, which is guaranteed to be also in order by name. Your FCITbook program will read in a serious of commands from a file, such as ADD, DELETE, FRIEND, UNFRIEND, etc. You will need to process the commands and print the appropriate information to the output file. Input/Output Specifications The input file will be called FCITbook.in. The first line of the file will be an integer, k, indicating the number of commands that will be run on the database. The following k lines will each be a single command, with the relevant data on the same line, separated by spaces. The commands you will have to implement are as follows: ADD Creates a new FCITbook account (a new node). The command will be followed by the following information: ID, a non-negative int variable, which you will use to sort the accounts by, a first name and last name, each no longer than 20 characters, and the department to which they belong (CS, IS, or IT). FINDNAME This command will be followed by a name, first then last. You must search the database to find this name, and then print out some information about this person. It should print their name, department, and the number of Friends they have. If there is not a person by that name in the database, it should print an error message saying so. FINDID Similar to FINDNAME, this will find a person, based on their ID number instead. The output should be the same. It should print their name, age, and the number of Friends they have. If there is not a person by that name in the database, it

should print an error message saying so. FRIEND This will be followed by two names, first and then last for both. When you see this command, this means that the two people are now Friends, and thus you should add both people's IDs to each others' Friend-lists. All connections on FCITbook are always two-way e.g. if John is in Bob s Friend-list, then Bob is also in John's. If either person in the FRIEND command is not in the database, or if they are already Friends, an error message should be displayed (see sample output below). UNFRIEND This is the opposite of FRIEND. Like FRIEND, it will be followed by two names. You will have to find both names, and remove their IDs from each others' Friend-lists. Again, if either person is not in the database, or they are not actually Friends, an error message should be displayed. DELETE This command, followed by a name, means you must delete this user's account from the database. Before you do so, however, you must remove them from any other users' Friend-lists. Thus, for the user you are deleting, you will need to loop through their own Friend-list, and find all of their Friends by searching for their IDs, and run your UNFRIEND command to remove them from each others' lists. If the person you are trying to delete does not actually have an account already, an error message should display. PRINTFRIENDS This command, followed by a name, first then last, prints the member s name, the number of friends they have, and then it prints an alphabetical list of their friends and which department they are in. PRINTMEMBERS This command prints all members in alphabetical order (last name, and then first name), along with printing basic information about these members (see output below). Your program must output to a file, called FCITbook.out. You must follow the program specifications exactly. You will lose points for formatting errors and spelling. See sample input and output files for examples. ***WARNING*** Your program MUST adhere to this EXACT format (spacing capitalization, use of colons, periods, punctuation, etc). The graders will use very large input files, resulting in very large output files. As such, the graders will use text comparison programs to compare your output to the correct output. If, for example, you have two spaces between in the output when there should be only one space, this will show up as an error even through you may have the program correct. You WILL get points off if this is the case, which is why this is being explained in detail. Minimum deduction will be 10% of the grade, as the graders will be forced to go to text editing of your program in order to give you an accurate grade. Helpful Suggestions / Comments The binary search tree code and the linked list code on the website use integers throughout the examples (int data). My intention is for you to basically, with only minor changes, reuse that code meaning, we want this to be easy for you. So for just about ALL of the commands, whenever you read in a first and last name, the FIRST thing you should do is call a method (that you will make) called getid. This method sends over the root of the tree, the

first and last name in question, and then returns the ID of that user. So now, at that point, you have an int ID and can basically use the code on the website without much modification. Of course, making the method mentioned above, getid, will require you to do a binary search on the tree based on string compare of last and first names. So you will need to write that yourself (by modifying the findnode method in the code on the website). But again, once done, you have an int ID and can reuse a lot of the code on the website. Grading Details Your program will be graded upon the following criteria: 1) Adhering to the implementation specifications listed on this write-up. 2) Your algorithmic design. 3) Correctness. 4) Use of Binary Search Trees with Linked Lists. Since the purpose of this assignment is to teach you to Binary Search Trees, you will not receive credit if you don't use them. 5) The frequency and utility of the comments in the code, as well as the use of white space for easy readability. (We're not kidding here. If your code is poorly commented and spaced and works perfectly, you could earn as low as 85-90% on it.) 6) Compatibility to the newest version of NetBeans and Java. (If your program does not compile in NetBeans, you will get a sizable deduction from your grade.) 7) Your output MUST follow to the EXACT output format shown in the sample output file. 8) Your program should include a header comment with the following information: your name, course number, section number, assignment title, date, AND EMAIL ADDRESS. 9) You should include comments throughout your code, when appropriate. Deliverables You should submit a zip file with FIVE files inside: 1. FCITstudent.java Class to create object of type FCITstudent 2. FCITbookBST.java Class to create objects of type FCITbookBST. You will only make ONE object of this class. This is the class for the BST. The code should be very similar to the code on the website. 3. FCITfriends.java Class to create objects of type FCITfriends. This is the Linked-List class. Each student will have a reference to their list of Friends. And this reference will point to a linked-list object (an object of type FCITfriends). 4. FCITfriend.java Class to create objects of type FCITfriend. This class is to make nodes of the linked list mentioned above (FCITfriends). 5. FCITbook.java This is your main program. NOTE: your name, ID, section and EMAIL should be included as comments in all files!

Here are the UML Diagrams for the required classes: FCITstudent private int ID private String firstname private String lastname private String department private int numfriends private FCITfriends myfriends private FCITstudent right private FCITstudent left FCITstudent is used to make objects of the BST. ID, firstname, lastname, and department should be obvious numfriends is the number of friends that this student has myfriends is a reference to an object of type FCITfriends (a linked-list). This linked-list will store all the friends of this student. left and right are the left and right pointers of this node (for the BST). FCITfriends private FCITfriend head; All required methods for a Linked-List class This is the Linked-List class. It should be very similar to the linked-list class on the website or used for Program 2. All nodes of this class are of type FCITfriend, which is shown below. FCITfriend private int ID; private FCITfriend next; This is the class to make nodes of the linkedlist of friends. Each FCITstudent has a variable called myfriends. This variable is FCITbookBST private FCITstudent root All required methods for a BST This is the BST class used to create one object of type FCITbookBST This class should be VERY similar to the BST class shown on the course website.