Write a Prolog program that implements the following predicates for an AVL tree: insert(I,T1,T2) is true if T2 is the AVL tree resulting from I being inserted into an AVL tree T1. display(T) is always true prints the AVL tree to the display.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

(!!!!THE SOLUTION MUST BE WRITTEN IN PROLOG, DO NOT USE THE CODE FROM STACKOVERFLOW!!!)

An AVL tree is a binary tree for which a special condition holds throughout the tree, namely, that at every node the height of the left and right subtrees differ by at most 1. A binary tree can be defined in terms of 2 predicates:

  • empty, the empty binary tree
  • bt(N,T1,T2) that is true if N is the root of a binary tree with left subtree T1 and right subtree T2, where all the items in T1 are less than or equal to N and all the items in T2 are greater than N.

Write a Prolog program that implements the following predicates for an AVL tree:

  • insert(I,T1,T2) is true if T2 is the AVL tree resulting from I being inserted into an AVL tree T1.
  • display(T) is always true prints the AVL tree to the display.

 

(!!!!THE SOLUTION MUST BE WRITTEN IN PROLOG, DO NOT USE THE CODE FROM STACKOVERFLOW!!!)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education