I am doing a project where i have to insert a list of players and stats into a binary search tree
Here is the project description

For this final assignment, you will be creating a binary search tree. You will be able to utilize some of your previous assignment code, but this assignment will be somewhat different. The menu options will be as follows:

* 1 - List all players stats (in-order)
* 2 - List all players stats (pre-order)
* 3 - List all players stats (post-order)

Each of these options should be recursive functions following the logic and examples discussed in class. You should also have a function to do the inserting (again recursively as shown in class).

The first thing you should do, is define your structure to hold the player information. The input file has changed, and you have more information to capture about each player (as well as more players). The information for each player is as follows (in order):

* Team Abbreviation
* Player Number
* Player First Name
* Player Last Name
* Player Position
* Number of Passing Yards
* Number of Passing Touchdowns
* Number of Rushing Yards
* Number of Rushing Touchdowns
* Number of Receptions
* Number of Reception Yards
* Number of Reception Touchdowns

The next step to do, is define your logic for how to insert each of the player structures into a binary search tree. This may take a bit of time, so get a head start on this. As a hint, I created two functions for this (one to iterate reading entries from the file, and the other is called as each player structure is created to put into the binary tree). For a key, you should use the player last name, and then first name. As another hint, I would suggest creating another string in your structure to hold the whole name (just make sure it has a size that can handle both the first and last names).

Lastly, work on the displaying of players. The coding is very simple for this, but the logic is recursive and may take a little bit to think out. Stick to the logic provided and use the examples shown in class to help you through.

here's what i have so far

``````/* Bradley Koperski
CIS 126
Project 9
*/

/* This program reads football statistics of players on the Chicago Bears from a
text files and disblay the desired information via a numbered menu system.
*/

#include<stdio.h>
#include<string.h>
# define TYPED_ALLOC(type) (type *)malloc(sizeof (type)
/* define player structure */
typedef struct player
{
char team[3]
int number, passyards, rushyards, recpyards, passTD, rushTD, recpTD, receptions ;
char fname[30];
char lname[30];
char pos[4];
} playerdata;

typedef struct tree_node_s
{
int key;
struct tree_node_s *leftptr, rightptr;
} tree_node_t

typedef tree_node_t *rootp
void insertNode( rootp *, int );
void inOrder( rootp );
void preOrder( rootp );
void postOrder( rootp );

int
main(void)
{
tree_node_t *bstreep; /* Binary Search Tree */
int data_key;

tree_node_t treeinsert(tree_node_t *rootp, int new_key)
{
if (rootp==NULL)
{
rootp = TYPED_ALLOC(tree_node_t);
rootp->key = new_key;
rootp->leftp = NULL;
rootp_>rightp = NULL
}

else if (new_key == rootp->key)
{
}
/* Insert in left subtree */
else if (new_key < rootp->key)
{
rootp->leftp = treeinsert(rootp->leftp, new_key);
} /* End Insert */

/* Insert in right subtree */
else
{
rootp->rightp = treeinsert(rootp->rightp, new_key);
} /* End Insert */

return (rootp);
}
/* End treeinsert */``````

can someone help me out a little with this

Here is an update of my code status:

``````/* Bradley Koperski
CIS 126
Project 9
*/

/* This program reads football statistics of players on the Chicago Bears from a
text files and disblay the desired information via a numbered menu system.
*/

#include<stdio.h>
#include<string.h>
# define TYPED_ALLOC(type) (type *)malloc(sizeof (type)
/* define player structure */
typedef struct player
{
char team[3]
int number, passyards, rushyards, recpyards, passTD, rushTD, recpTD, receptions ;
char fname[30];
char lname[30];
char pos[4];
} playerdata;

typedef struct tree_node_s
{
char key;
struct tree_node_s *leftptr, rightptr;
} tree_node_t

typedef tree_node_t *rootp
void insertNode( rootp *, int );
void inOrder( rootp );
void preOrder( rootp );
void postOrder( rootp );

int
main(void)
{
tree_node_t *bstreep; /* Binary Search Tree */
int data_key;
}

/* Fill Search tree */
tree_node_t treeinsert(tree_node_t *rootp, char new_key)
{
if (rootp==NULL)
{
rootp = TYPED_ALLOC(tree_node_t);
strcpy(rootp->key,new_key);
rootp->leftp = NULL;
rootp_>rightp = NULL
}

else if (new_key == rootp->key)
{
}
/* Insert in left subtree */
else if (strcmp(new_key ,rootp->key))<0)
{
rootp->leftp = treeinsert(rootp->leftp, new_key);
} /* End Insert */

/* Insert in right subtree */
else
{
rootp->rightp = treeinsert(rootp->rightp, new_key);
} /* End Insert */

return (rootp);
}
/* End treeinsert */``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.