MESSAGE
DATE | 2015-01-22 |
FROM | Ruben Safir
|
SUBJECT | Subject: [LIU Comp Sci] Algorithms Assignment 1 attempt
|
From owner-learn-outgoing-at-mrbrklyn.com Thu Jan 22 19:30:26 2015 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id 469AE16115E; Thu, 22 Jan 2015 19:30:26 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id 3726E161165; Thu, 22 Jan 2015 19:30:26 -0500 (EST) Delivered-To: learn-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by mrbrklyn.com (Postfix) with ESMTP id B636316115E for ; Thu, 22 Jan 2015 19:30:25 -0500 (EST) Received: from [10.0.0.19] (unknown [96.57.23.82]) by mailbackend.panix.com (Postfix) with ESMTPSA id D4A63147A6 for ; Thu, 22 Jan 2015 19:30:24 -0500 (EST) Message-ID: <54C19620.5070706-at-panix.com> Date: Thu, 22 Jan 2015 19:30:24 -0500 From: Ruben Safir User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: learn-at-nylxs.com Subject: [LIU Comp Sci] Algorithms Assignment 1 attempt Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: owner-learn-at-mrbrklyn.com Precedence: bulk Reply-To: learn-at-mrbrklyn.com
I've loaded my version of assignment 1 onto the NYLXS webserver at
http://www.nylxs.com/docs/grad_school/algorithms/hw/ass_1_lists/list.cpp.html
http://www.nylxs.com/docs/grad_school/algorithms/hw/ass_1_lists
Look it over and please edit and comment
A few thoughts:
First, I changed to order of the function listings because we are not using function declarations so the order that they are defined is essential because they call each other. Ideally, one would make a .h file.
Secondly, the given skeleton was essentially broken and I had to rewrite all the functions. As it was, it not only didn't track the last entries correctly near L.n == L.last, but also used an incorrect algorithm to find is a list was full
Thirdly, I reduced the size of the array from 100 to 5 so I could debug it and show who it works.
Fourthly, it takes some interpretation of the intent of the assignment specifications to correctly right the code. This is all to common of a problem. Give me the Spec! (I guess UML might be good for something). As such, when the array is full and I'm adding from the last, then I chose to push results forward and bump the first value. Likewise, for InsertBegin, I push everything forward. He wrote this, actually, but I filled in the case of what to do when the array is filled. I then give a warning and bump the last value out of the array.
Fifth: See my makefile and do yourself a favor and copy it and use it. BTW - GVIM is your friend.
Sixth: I let debugging code in my code. You can best run it like this
list 2> /dev/nulll
Even with that, it is quite chatty.
Ruben
|
|