MESSAGE
DATE | 2015-02-25 |
FROM | Keisha Sylvester
|
SUBJECT | Re: [LIU Comp Sci] Binary tree Excersize
|
From owner-learn-outgoing-at-mrbrklyn.com Wed Feb 25 12:26:05 2015 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id 5EED1161162; Wed, 25 Feb 2015 12:26:05 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id 1EC13161168; Wed, 25 Feb 2015 12:26:05 -0500 (EST) Delivered-To: learn-at-mrbrklyn.com Received: from mail-qg0-f54.google.com (mail-qg0-f54.google.com [209.85.192.54]) by mrbrklyn.com (Postfix) with ESMTP id 49551161162 for ; Wed, 25 Feb 2015 12:26:03 -0500 (EST) Received: by mail-qg0-f54.google.com with SMTP id z60so4102930qgd.13 for ; Wed, 25 Feb 2015 09:26:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-type:content-transfer-encoding :mime-version:subject:date:references:in-reply-to:to:message-id; bh=bCc4qEABY+o4gXGfbvsVf8Yzht21C1ve8pKve3cAB28=; b=a47F7qRMf/aiFzKYHs99VTPmXkwqkIlKrkYU/uG5o/LufXxIThG26jHLzBLslLUI8V YWMN7VsXScwb7UTzBsXQZo32Xy/9nZO6DwgvszHSPpsct7i1qdkB99SvJkjF9/nuoWlR gCIJclVu/WxPyHdNXQSnJZwz5+gQ/po4ch3O0R9HFATznNGSETNjl95HzjY3MmLeJr4F 6Ctx/NLhyopJJILe9lK735PtCFXe4GFAgAc5o26fgEyYIlEzvZerFQJx7JxTHuaHTDMp TIUCPo7C4CH5MJnZHQPuLnTGbHXy6sy6ooYsHXU7aW1MukoIlS9yzPmgOcF6d6zvre1F qZjg== X-Gm-Message-State: ALoCoQmacSOSs6A8hticGeAtVsMq0q/1XHIO129KFR0j05WaDk83TUpgMe7xbmlTLZI+41WfSqQG X-Received: by 10.140.89.111 with SMTP id u102mr8849262qgd.20.1424885162640; Wed, 25 Feb 2015 09:26:02 -0800 (PST) Received: from [148.4.98.24] ([148.4.98.24]) by mx.google.com with ESMTPSA id 76sm21849860qhs.5.2015.02.25.09.26.01 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Feb 2015 09:26:01 -0800 (PST) From: Keisha Sylvester X-Google-Original-From: Keisha Sylvester Content-Type: multipart/alternative; boundary=Apple-Mail-05663676-A9B2-4333-A7E5-A0F461771FC4 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Subject: Re: [LIU Comp Sci] Binary tree Excersize Date: Wed, 25 Feb 2015 12:13:00 -0500 References: <54EB4BE9.6020505-at-panix.com> <54EBF7E1.2070605-at-panix.com> <54EBFCC9.8070605-at-my.liu.edu> <54EDCB27.5080904-at-my.liu.edu> <54EDCC82.2090800-at-panix.com> In-Reply-To: <54EDCC82.2090800-at-panix.com> To: "learn-at-mrbrklyn.com" Message-Id: <3DDAC115-E003-494C-8FEA-9A31DB7B13A4-at-my.liu.edu> X-Mailer: iPad Mail (12B410) Sender: owner-learn-at-mrbrklyn.com Precedence: bulk Reply-To: learn-at-mrbrklyn.com
--Apple-Mail-05663676-A9B2-4333-A7E5-A0F461771FC4 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
Ruben, What time will you be in school today?
Keisha G. Sylvester
Sent from my iPad
> On Feb 25, 2015, at 8:22 AM, Ruben Safir wrote: > >> On 02/25/2015 08:16 AM, Ruben wrote: >>> On 02/24/2015 12:32 PM, Maneesh Kongara wrote: >>> int node_count(const BinTree& node) >>>> { >>>> int static count = 0; >>>> if(node == 0) >>>> { >>>> return count; >>>> } >>>> node_count(node->left); >>>> node_count(node->right); >>>> count++; >>>> return count; >>>> } >> >> this is the part that was my solution for the homework. >> >> It is the extra credit part that is worthy of discussion. >> > > > BTW - I don't like the use of statics in these functions. What if you > have to count twice? It is better to declare the variable outside the > function and then either pass it in by reference or use make an external > reference or pointer to the external counter. This way you can zero it > if you need to. > > Ruben
--Apple-Mail-05663676-A9B2-4333-A7E5-A0F461771FC4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
utf-8">Ruben, What time will you be= in school today? Keisha G. Syl= vester
iv>Sent from my iPad"cite">On 02/25/2015 08:16 AM, Ruben wrote: type=3D"cite">On 02/24/2015 12:32 PM, Maneesh Kongara wrote:r> int= node_count(const BinTree& node)
ockquote type=3D"cite"><= span>{
cite">  = ; int static count =3D 0;
ote>cite"> if(node =3D=3D 0)
ockquote> lockquote type=3D"cite"> {
= blockquote>
=
r= eturn count;
pe=3D"cite">  = ; }
ype=3D"cite"> &nbs= p; node_count(node->left);
> e type=3D"cite"> node_count(node->right);<= br>
ote type=3D"cite"> count++= ;
> &nbs= p;return count;
type=3D"cite">}= span>
pan>
this is the part= that was my solution for the homework.
ype=3D"cite">
I= t is the extra credit part that is worthy of discussion. ote>
> BTW - I don't like the use of statics in these funct= ions. What if you have to count twice? It is bet= ter to declare the variable outside the function and then ei= ther pass it in by reference or use make an external referen= ce or pointer to the external counter. This way you can zero it=
if you need to.
Ruben <= /div> = --Apple-Mail-05663676-A9B2-4333-A7E5-A0F461771FC4-- |
|