COP4530 Data Structures, Algorithms and Generic Programming Recitation 3 Date: January 20 & 22, 2009

Similar documents
Laboratory 1 Semester 1 11/12

CpSc 1111 Lab 9 2-D Arrays

Programming Tips for CS758/858

Lab 1: Accessing the Linux Operating System Spring 2009

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

CS354 gdb Tutorial Written by Chris Feilbach

Projects and Environment Introduction

CIS* Programming

Problem Set 1: Unix Commands 1

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

We first learn one useful option of gcc. Copy the following C source file to your

Lab 1 Introduction to UNIX and C

Temple University Computer Science Programming Under the Linux Operating System January 2017

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

Laboratory Assignment #3 Eclipse CDT

CS111: Intro to Computer Science

Lab 1: Dynamic Memory: Heap Manager

Intermediate Programming, Spring Misha Kazhdan

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

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

15-411/ Compiler Design

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

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

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

Homework 1 CS 642: Information Security

Object Oriented Programming Using C++

Unit 13. Linux Operating System Debugging Programs

CS 241 Data Organization using C

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

/ Cloud Computing. Recitation 2 January 19 & 21, 2016

CS1600 Lab Assignment 1 Spring 2016 Due: Feb. 2, 2016 POINTS: 10

Lab 1 Introduction to UNIX and C

CS 051 Homework Laboratory #2

Engr 123 Spring 2018 Notes on Visual Studio

CMSC 201 Spring 2017 Lab 01 Hello World

CMPSCI 187 / Spring 2015 Sorting Kata

Repetitive Program Execution

CS 3030 Scripting Languages Syllabus

WRITING CONSOLE APPLICATIONS IN C

Jackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 5

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

Exercises: Instructions and Advice

Assignment 1: PostgreSQL Buffer Manager

CS 253: Intro to Systems Programming 1/21

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

EXPERIMENT 1. FAMILIARITY WITH DEBUG, x86 REGISTERS and MACHINE INSTRUCTIONS

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

You should see something like this, called the prompt :

Adding Content to Blackboard

CS 246 Winter Tutorial 1

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Introduction to MATLAB

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

Network Administration/System Administration (NTU CSIE, Spring 2018) Homework #1. Homework #1

ECE 3574: Applied Software Design

15-122: Principles of Imperative Computation

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

CS 261 Recitation 1 Compiling C on UNIX

CMSC 201 Spring 2019 Lab 06 Lists

Practical Programming Methodology

Lab 3-2: Exploring the Heap

Click on the Start Icon. Click on All Programs

AMS 200: Working on Linux/Unix Machines

CS 241 Data Organization. August 21, 2018

Linux Survival Guide

:

Recitation #1 Boot Camp. August 30th, 2016

Development Environment & Linux Guide

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

CMSC 201 Spring 2018 Lab 01 Hello World

ECE 3210 Laboratory 1: Develop an Assembly Program

Using the Zoo Workstations

Code::Blocks Student Manual

The following are the requirements for the password server client program named pass.cpp:

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

Operating System Labs. Yuanbin Wu

Problem Set 1 Due: 11:59pm Wednesday, February 7

CS 642 Homework #4. Due Date: 11:59 p.m. on Tuesday, May 1, Warning!

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "

One of the hardest things you have to do is to keep track of three kinds of commands when writing and running computer programs. Those commands are:

CMSC 201 Fall 2018 Lab 04 While Loops

CS 378 (Spring 2003) Linux Kernel Programming. Yongguang Zhang. Copyright 2003, Yongguang Zhang

An Introduction to Blackboard for Students

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

Code::Blocks Student Manual

Project 1 Balanced binary

CMPSCI 120 Fall 2013 Lab #2 Professor William T. Verts

Operating Systems, Spring 2015 Course Syllabus

CSCI 3300 Assignment 3

15-110: Principles of Computing, Spring 2018

Computer Science II Lab 3 Testing and Debugging

Spring 2017 Gabriel Kuri

CS 1044 Program 6 Summer I dimension ??????

CS503 Advanced Programming I CS305 Computer Algorithms I

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

CSC D84 Assignment 2 Game Trees and Mini-Max

CS155: Computer Security Spring Project #1. Due: Part 1: Thursday, April pm, Part 2: Monday, April pm.

Transcription:

COP4530 Data Structures, Algorithms and Generic Programming Recitation 3 Date: January 20 & 22, 2009 Lab objectives: 1) Quiz 2) Set up SSH to run external programs. 3) Learn how to use the DDD debuger. 4) Learn to use the list STL. 5) Discussion and Q & A about Assignment 1. Setup tasks: 1. Under the Start menu, find the folder named X-Win32 and open the Xutils32. 2. Start the SSH client. When the shell opens, go to Edit Settings and then go to Tunneling. 3. Check the box that says Tunnel x11 con and click OK. Now it is possible to run text editors in separate windows from the SSH console. Fo emacs for example, just type xterm emacs followed by the file name to be edited, and a separate emacs window will appear. 4. Logon to your CS account. 5. Create a directory named cop4530. 6. Go into the cop4530 directory and create a sub-directory named recitation. 7. Go into the recitation directory. Type the command pwd. You should see something similar to the following on the screen: /home/majors/your_username/cop4530/recitation 8. Type the following command, cp r ~cop4530/spring09/recitation/rect3. You should see some error messages similar to the following, cp: cannot open `/home/courses/cop4530/spring09/recitation/rect3/lists/readstudent.cpp' for reading: Permission denied cp: cannot open `/home/courses/cop4530/spring09/recitation/rect3/wcountgood.cpp' for reading: Permission denied Note: The warnings above indicate that some files cannot be read because the permissions have been set to non-world viewable. 1

Task 1 : Learn to use the DDD debugger. A debugger allows us to run other program executables and examine the behavior of these programs as they are running. Debuggers are especially helpful when there is a mysterious bug in the program that is not apparent at first glance. One of the more popular debuggers for UNIX would be the GDB (the GNU debugger). A graphical front-end version of GDB is known as the DDD. 1. Open the file wcount-bad.cpp. 2. Compile the program and run the executable. The desired effect of the program should be as follows: i. The user is allowed to add enter 3 distinct words. If the word entered already exists, the count for the word is incremented for each repeated entry. ii. The program should not accept any new words if all 3 slots are full. The desired output for the program is as follows: one two three four Array is full. Cannot add word. one three -1 Exiting program.. wordarray[0] = one, count = 2 wordarray[1] = two, count = 1 wordarray[2] = three, count = 2 3. This program has logic errors. Use the DDD debugger to determine the location of the error. 4. Fix the error to produce the desired output above. Hint: An unused function in the program will be helpful. 2

A sample solution will be provided in the file wcount-good.cpp. This file will be made available by 3:00 p.m. Thursday (January 22, 2008). You may obtain the file by typing the following in your current directory: cp ~cop4530/spring09/recitation/rect3/wcount-good.cpp. Exercise Log on to linprog.cs.fsu.edu and use the DDD debugger to solve a bug problem with an executable created from the file squares-bad.cpp located in your rect3 directory. Task 2 : Learn to use the list STL. 1. Go into the lists directory. 2. Open the file readname.cpp. This client program uses the list STL to store in names keyed in by the user. When the user is done, the program prints out all the names stored in the linked-list. 3. Suppose you wish to write a similar program to print out some student information. This program should store the name, age and section of each student. i. Modify the program readname.cpp to prompt the user for the age and section corresponding to each name. ii. Store all three information about each student in a single linked-list. iii. Use a FOR or WHILE-loop to print out the information stored in the linked list. 4. A sample output for such a program is shown below: Enter name ('exit' when done): Susana Enter age: 19 Enter section: 1 Enter name ('exit' when done): Lucas Enter age: 21 Enter section: 2 Enter name ('exit' when done): Arturo Enter age: 23 Enter section: 1 3

Enter name ('exit' when done): Jane Enter age: 20 Enter section: 2 Enter name ('exit' when done): exit Name = Susan, Age = 19, Section = 1 Name = John, Age = 21, Section = 2 Name = Bill, Age = 23, Section = 1 Name = Janet, Age = 20, Section = 2 Sample solutions will be provided in the file lists/readstudent.cpp. This file will be made available by 3:00 p.m. today (January 22, 2009). You may obtain the files by typing the following command in your current directory. cp ~cop4530/spring09/recitation/rect3/lists/readstudent.cpp Task 3: Discussion and Q& A about Assignment 1 Advice from TA: 1. Read the project requirements carefully. You should attempt to satisfy all the requirements of the project. Your executable will be tested with an automated script, so your program should behave in the same way as the executable. Your program should also print out the output in the same manner as the executable. When in doubt, clarify with instructor or TA. Do not assume. 2. Plan ahead before you code. You should decide on how you need to store the data so that it can be efficiently accessed when needed. 3. Familiarize yourself with the reading and parsing input. This is one of the more fun parts of the project. You get to practice/hone some of your programming skills in parsing input. 4. Test your program extensively and write your own test files. Do not presume that your program will only be tested with the sample input data already provided. 5. Use I/O redirect to test your program with an input test file. A sample file input.txt is provided to you. You can test your program by typing, proj1 FLIGHTS.txt < input.txt 6. Seek help from instructor or TAs if you are stuck for too long. 4

If you have been staring at the same segment of code for the past 3 hours and still can t figure out what is wrong, you need help! Submit your current work using the submission script and email me at chatterj@cs.fsu.edu with a brief description of your problem. 7. Adhere to good programming styles and practices as your program will be graded on design and readability (see Syllabus), e.g. indent your code, include comments on major subroutines or algorithms (but not on every line of code), close all open file descriptors, and etc. 8. Do your own work. Q & A:? References Topic Links Templates 1. http://www.cplusplus.com/doc/tutorial/tut5-1.html DDD Debugger 1. http://www.gnu.org/manual/ddd/html_mono/ddd.html 5