MESSAGE
DATE | 2015-02-22 |
FROM | Ruben
|
SUBJECT | Re: [LIU Comp Sci] Binary tree Excersize
|
From owner-learn-outgoing-at-mrbrklyn.com Sun Feb 22 19:49:19 2015 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id 5A21816118F; Sun, 22 Feb 2015 19:49:19 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id 4ADD9161191; Sun, 22 Feb 2015 19:49:19 -0500 (EST) Delivered-To: learn-at-nylxs.com Received: from mail-qa0-f50.google.com (mail-qa0-f50.google.com [209.85.216.50]) by mrbrklyn.com (Postfix) with ESMTP id 8649816118F for ; Sun, 22 Feb 2015 19:49:17 -0500 (EST) Received: by mail-qa0-f50.google.com with SMTP id f12so20169674qad.9 for ; Sun, 22 Feb 2015 16:49:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=NOQkNdhYy9isFRoagdJWsB8WqPSYhv/FYsvFIKwxC8o=; b=I+msS+cPx8B9Kuw7ayz8wP4CRQi+tR7OaQfyLOGpWDbFNMazmsYQsAreKilVdzNakn x7I2MaUG7G0UOXWJDbVweny0qLqwOAmhQ/WsqJ3P2Bjym0Xvvpi3LyY7EB+ZyfH7uueO UxiWfUJDIHc9bLyQrkgaobSFkV/l/gmsQeJyN74Jd5FxDa8Dkd3cYYYE4m2k+haA9UTQ XXq6EwKrHzZsnNTDlxY4HEDCwycHWbzqQ7oYhY/n3yA29JiyrOHFLdlht3EyzOz0wJ6S o3fIpoJW7aH6S7Wva65G79Ult0eHbevy/9tsJ5kC9GQXBxejY+n8NtPWDYFC+6aOjVRK QeCw== X-Gm-Message-State: ALoCoQni7x3Rx/f85skvMkHqNTPI+M7q08Asey3Y/Uwns5wua73PfFSxGLxJN637MCckSR+4fGLO X-Received: by 10.140.87.7 with SMTP id q7mr18659901qgd.67.1424652556176; Sun, 22 Feb 2015 16:49:16 -0800 (PST) Received: from [10.0.0.19] ([96.57.23.82]) by mx.google.com with ESMTPSA id r6sm10316812qah.43.2015.02.22.16.49.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Feb 2015 16:49:15 -0800 (PST) Message-ID: <54EA790A.3080304-at-my.liu.edu> Date: Sun, 22 Feb 2015 19:49:14 -0500 From: Ruben User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: jose.rodriguez-at-liu.edu Subject: Re: [LIU Comp Sci] Binary tree Excersize References: <54E986CC.1080008-at-panix.com> In-Reply-To: <54E986CC.1080008-at-panix.com> 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
On 02/22/2015 02:35 AM, Ruben Safir wrote: > I'm attaching a example of the Binary Tree which is based on Dr > Rodriquez's example EXCEPT, well this one is much easier to learn about > binary trees from and I strongly recommend looking it over and trying it > out. > > Ruben >
This sample from the notes doesn't work...
The reason it doesn't work is because it is called recursively and at the end of tree the root is 0 (null) and then it returns -1.
Ruben
int Height(BinTree& root) { if (root == 0) return -1; int hl = Height(root->left); int hr = Height(root->right); return 1 + ((hl < hr)?hr:hl); }
|
|