Avl tree help

This is a discussion on Avl tree help within the Tech Board forums, part of the Community Boards category; can anyone implement these two functions ? Code: int avl_insert(avl_t * tree, avl_key_t key, data_t data) data_t avl_remove (avl_t *tree, ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    1

    Post Avl tree help

    can anyone implement these two functions ?
    Code:
    int avl_insert(avl_t * tree, avl_key_t key, data_t data) 
    
    data_t avl_remove (avl_t *tree, avl_key_t key)
    
    giving this struct
    
    typedef void * data_t;
    
    
    
    
    typedef struct avl_node_tag{ 
       data_t data_ptr;
    
       avl_key_t key;
    
       struct avl_node_tag * left;
    
       struct avl_node_tag * right;
       int height;
    
    }  avl_node_t;
    
    
    
    typedef struct avl_tag{ 
       avl_node_t * root;
    
       int tree_size;
       AVLComparator comparator;
    
       int num_recent_key_comparisons;
    
    }  avl_t;

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    > can anyone implement these two functions ?
    Yes, but that isn't the point of homework is it?

    You "attempt", we "help".

    Not "you dump assignment and go party" and we "spend hours getting you a good grade".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,612
    But what is an AVL tree doing in the AI section?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Good point - moved.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  2. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 08:09 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21