MESSAGE
DATE | 2016-11-17 |
FROM | Ruben Safir
|
SUBJECT | Re: [Learn] [Hangout-NYLXS] at K&R now
|
From learn-bounces-at-nylxs.com Thu Nov 17 23:32:52 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 8B9A4161315; Thu, 17 Nov 2016 23:32:52 -0500 (EST) X-Original-To: learn-at-nylxs.com 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 3F120160E77; Thu, 17 Nov 2016 23:32:41 -0500 (EST) Received: from [10.0.0.62] (www.mrbrklyn.com [96.57.23.82]) by mailbackend.panix.com (Postfix) with ESMTPSA id 88CCD1346D; Thu, 17 Nov 2016 23:32:41 -0500 (EST) To: hangout-at-nylxs.com, learn-at-nylxs.com References: <20161118003458.GA4067-at-www.mrbrklyn.com> From: Ruben Safir Message-ID: <1df34481-3c63-65a7-9c90-c65f6fbdbeb9-at-panix.com> Date: Thu, 17 Nov 2016 23:32:41 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161118003458.GA4067-at-www.mrbrklyn.com> Subject: Re: [Learn] [Hangout-NYLXS] at K&R now X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
On 11/17/2016 07:34 PM, Ruben Safir wrote: > anyone else dropping in at te Kilarny Rose? > We are set up downstairs near the power > > Ruben > so in the end, we were perplexed with the simple problem of mapping an array of random numbers into a binary tree
so here is an array of random numbers
using namespace std;
int *data = new int[SIZE]; // int *cache = new int[SIZE]; struct timespec now; clock_gettime(CLOCK_REALTIME, &now); long seed = now.tv_nsec; srand( (unsigned int) seed); for(int i = 0; i < SIZE; i++){ data[i] = rand() % 1000000; cout << data[i] << "\t"; } cout << endl;
make a node class Node { public:
/* ==================== LIFECYCLE ======================================= */ Node (): _parent{nullptr}, _left{nullptr}, _right{nullptr}{}; /* constructor */ Node (Node * par): _parent{par}, _left{nullptr}, _right{nullptr}{}; /* constructor */ Node ( const Node &other ); /* copy constructor */ ~Node (); /* destructor */
/* ==================== ACCESSORS ======================================= */ Node * parent(){ retun _parent; } Node * left() const{ return _left; } Node * right() const{ return _right; } int value() const{ return _value; } int max() const{ return _max; } Node * parent(Node * in){ _parent = in; return _parent; } Node * left(Node * in){ _left = in; return _left; } Node * right(Node *in){ _right = in; return _right; } int value(int in){ _value = in; return _value; } int max(int in){ _max = in; return _max; }
/* ==================== MUTATORS ======================================= */
/* ==================== OPERATORS ======================================= */
const Node& operator = ( const Node &other ){ left(other.left()); right(other.right()); value(other.value()); max(other.max()); return * this; }; /* assignment operator */
/* ==================== DATA MEMBERS ======================================= */ protected:
private: Node *_parent; Node *_left; Node *_right; int _value; int _max; }; /* ----- end of class Node ----- */
now how you you build the tree. We tried a few mothods and nothing shook out
-- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|