Binary Tree and Objective-c
I am learning Objective-c at this moment. Read Stephen Kochan's book and now I am trying to write a binary tree.
My head isn't completely thinking Objective-c yet.
Has anyone implemented a simple BT in Objective-c and wouldn't mind sharing the code?
This is where I am at..
How would I set up the constructor? I am confused as to how to write the InsertValue in Objective-c.
Google didn't turn up anything on Objective-C and BTs. Nor did a search through this forum.
thanks.
Mike
Edit by mod (wyrmmage): Please surround your code in code tags for better clarity. I've done it for you this time
My head isn't completely thinking Objective-c yet.
Has anyone implemented a simple BT in Objective-c and wouldn't mind sharing the code?
This is where I am at..
Code:
#import <Foundation/Foundation.h>
// define the class interface
@interface Node : NSObject
{
Node *left;
Node *right;
int value;
}
-(void) InsertValue: (int) ivalue;
@end
@implementation Node
-(void) InsertValue: (int) ivalue
{
value = ivalue;
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Node *root = [[Node alloc]init];
[root InsertValue: 5];
// insert code here...
[pool drain];
return 0;
}Google didn't turn up anything on Objective-C and BTs. Nor did a search through this forum.
thanks.
Mike
Edit by mod (wyrmmage): Please surround your code in code tags for better clarity. I've done it for you this time
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Reading Binary Files | Nick | 15 | 5,660 |
Jul 12, 2005 03:53 AM Last Post: sealfin |
|

