MESSAGE
DATE | 2015-01-31 |
FROM | Ruben Safir
|
SUBJECT | Subject: [LIU Comp Sci] Linked List Homework
|
From owner-learn-outgoing-at-mrbrklyn.com Sat Jan 31 20:06:24 2015 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id B6BE0161186; Sat, 31 Jan 2015 20:06:24 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id A7203161191; Sat, 31 Jan 2015 20:06:24 -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 1F896161186 for ; Sat, 31 Jan 2015 20:06:23 -0500 (EST) Received: from [10.0.0.19] (unknown [96.57.23.82]) by mailbackend.panix.com (Postfix) with ESMTPSA id 33C8313420 for ; Sat, 31 Jan 2015 20:06:23 -0500 (EST) Message-ID: <54CD7C0E.5020808-at-panix.com> Date: Sat, 31 Jan 2015 20:06:22 -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] Linked List Homework 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
For the Algorithms class:
For what it is worth, there are a lot of errors inside of the code base for the linked list homework, which might make it very hard to actually do. The List Structure is NOT dependable as it is written and the Add Node after thingie is flatout written wrong.
You end up with a head node with a value of zero that is a dummy node... or a stupid node actually because it is not only not needed, but it doesn't belong and it generates errors.
My example for collaboration purposes is at
http://www.nylxs.com/docs/grad_school/algorithms/Hwk2/
specifically examine this
28 // InsertAfterNode: Create a new node containing val, and link it after np. 29 // This design is BROKEN. Nodes should never be handled directly but handled by the 30 // List structure which points to a specific node at all times. 31 // ALL List operations should happen through List 32 33 void InsertAfterNode(List& L, int val, node *np) 34 { 35 //this is broken - fix head 36 if(L.iter_pos == 0){ 37 L.head = np; 38 L.head->data = val; 39 L.head->next = 0; 40 L.tail = L.head; 41 L.iter_pos = L.head; //initialize the list location 42 return; 43 } 44 45 node *np2 = new node; 46 np2->data = val; 47 np2->next = np->next; 48 np->next = np2; 49 50 if (np2->next == 0) L.tail = np2; 51 } 52
|
|