Git Product home page Git Product logo

set's Introduction

Table of contents

Overview

What AVL-tree is?

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for all nodes.

An Example Tree that is an AVL Tree:

Image alt

The above tree is AVL because differences between heights of left and right subtrees for every node is less than or equal to 1.

An Example Tree that is NOT an AVL Tree:

Image alt

The above tree is not AVL because differences between heights of left and right subtrees for 8 and 18 is greater than 1.

Benefits of AVL-tree

Most of the BST operations (e.g., search, max, min, insert, delete.. etc) take O(h) time where h is the height of the BST. The cost of these operations may become O(n) for a skewed Binary tree. If we make sure that height of the tree remains O(Logn) after every insertion and deletion, then we can guarantee an upper bound of O(Logn) for all these operations. The height of an AVL tree is always O(Logn) where n is the number of nodes in the tree (See this video lecture for proof).

Features

The supported operations are:

  • void insert(const ValueType & key, Node **ptr, Node *parent = NULL)
  • void erase(const ValueType & key, Node **ptr>
  • Node * rotateleft(Node * ptr)
  • void rightBig(Node **vertex)
  • int getDepth(Node *ptr)
  • void updatDepth(Node *ptr)
  • int getBalance(Node *ptr)
  • void makeBalancePlus(Node **ptr)
  • void makeBalanceMinus(Node **ptr)
  • Node * Set :: balance(Node * ptr)

Requirements

The program code was written in the C ++ programming language, therefore, to compile the code, you must install g++. GNU C++ Compiler ( g++ ) is a compiler in Linux which is used to compile C++ programs.

sudo apt-get update sudo apt-get install g++

Compilation

make set

How to run program?

If you want to enter your oun set of input numbers, run the program as follows:./set

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.