From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bb89030c68b82ceb,start X-Google-Attributes: gid103376,public From: Gerald Ang Subject: help for my project Date: 2000/05/09 Message-ID: <3917F194.F6C1BB73@student.ecu.edu.au>#1/1 X-Deja-AN: 621067637 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353" Organization: Edith Cowan University Mime-Version: 1.0 Reply-To: tmang@student.ecu.edu.au Newsgroups: comp.lang.ada Date: 2000-05-09T00:00:00+00:00 List-Id: Help is needed for my assignment. Below is a copy of the specificaton code, please help with the Procedure Add. with Ada.Text_IO; with Unchecked_Deallocation; generic type Symbol is (<>); package Symbolized_Search_Tree is type Tree is private; type Symbol_Array is array(Integer range <>) of Symbol; type Sequence is access Symbol_Array; type Sequence_Array is array(Integer range <>) of Sequence; package Symbol_IO is new Ada.Text_IO.Enumeration_IO(Enum => Symbol); procedure Add(A_Tree: in out Tree; Symbols: in Symbol_Array; Result: out Integer); -- adds Symbols' non-shared elements to A_Tree and sets marker -- -- if no Symbols -- then -- Result:= -1 -- return -- end if -- -- if no A_Tree nodes -- then -- create root node, non-leaf nodes, leaf node -- assign Symbols' elements to root node, non-leaf nodes -- assign True to leaf node marker -- Result:= number of nodes created -- return -- end if -- -- determine number of Symbols' elements contained in A_Tree -- -- if A_Tree contains all Symbols' elements and True marker -- then -- Result:= -2 -- return -- end if -- -- if A_Tree contains all Symbols' elements and False marker -- then -- assign True to marker -- Result:= 0 -- return -- end if -- -- if A_Tree contains some of Symbols' elements -- then -- augment differing non-root node -- create non-leaf nodes, leaf nodes -- assign Symbols' tail elements to non-root node, non-leaf nodes -- assign True to leaf node marker -- Result:= number of nodes augmented/created -- return -- end if -- -- if A_Tree contains none of Symbols' elements -- then -- augment root node -- create non-leaf nodes, leaf node -- assign Symbols' elements to root node, non-leaf nodes -- assign True to leaf node marker -- Result:= number of nodes augmented/created -- return -- end if private type Node(Length: Integer); type Tree is access Node; type Tree_Array is array (Integer range <>) of Tree; type Node(Length: Integer) is record Marker: Boolean; Symbols: Symbol_Array(1..Length); Subtrees: Tree_Array(1..Length); end record; -- a leaf node has Length = 0 and Marker = True -- a partial-leaf node has Length > 0 and Marker = True -- a non-leaf node has Length > 0 and Marker = False -- for 1 <= I <= Length-1, Node.Symbols(I) < Node.Symbols(I+1) Null_Tree: constant Tree:= null; procedure Deallocate is new Unchecked_Deallocation(Object=>Node, Name=>Tree); end Symbolized_Search_Tree;