Table of Contents
Fetching ...

Implementing Binary Search Trees in GP 2 (Extended Abstract)

Ziad Ismaili Alaoui, Detlef Plump

TL;DR

This work demonstrates how binary search trees can be implemented in the GP 2 graph programming language using rooted graph transformation rules. The authors present a complete GP 2 program bst that supports insertion, querying, and deletion, with a worst-case time of $O(n)$ and an expected average of $O(\log n)$, intended to mirror imperative BST performance. The program uses a green root as a top proxy and traverses a user-supplied instruction list, handling three deletion scenarios and generating garbage nodes for removed elements. Runtime experiments compare degenerate and balanced trees, highlighting the impact of tree shape on performance and outlining future work toward balanced variants such as red–black trees and formal verification approaches.

Abstract

We present an approach to implement binary search trees in the rule-based graph programming language GP 2. Our implementation uses GP 2's rooted graph transformation rules to be fast and supports insertion, deletion and query operations. We argue that the worst-case runtime for each of the operations is O(n) for a tree with n nodes. In addition, we expect that, on average, the operations run in time O(log(n)). Hence the implementation would match the time complexity of binary search trees implementations in imperative languages.

Implementing Binary Search Trees in GP 2 (Extended Abstract)

TL;DR

This work demonstrates how binary search trees can be implemented in the GP 2 graph programming language using rooted graph transformation rules. The authors present a complete GP 2 program bst that supports insertion, querying, and deletion, with a worst-case time of and an expected average of , intended to mirror imperative BST performance. The program uses a green root as a top proxy and traverses a user-supplied instruction list, handling three deletion scenarios and generating garbage nodes for removed elements. Runtime experiments compare degenerate and balanced trees, highlighting the impact of tree shape on performance and outlining future work toward balanced variants such as red–black trees and formal verification approaches.

Abstract

We present an approach to implement binary search trees in the rule-based graph programming language GP 2. Our implementation uses GP 2's rooted graph transformation rules to be fast and supports insertion, deletion and query operations. We argue that the worst-case runtime for each of the operations is O(n) for a tree with n nodes. In addition, we expect that, on average, the operations run in time O(log(n)). Hence the implementation would match the time complexity of binary search trees implementations in imperative languages.
Paper Structure (11 sections, 5 figures)

This paper contains 11 sections, 5 figures.

Figures (5)

  • Figure 1: Example of a binary search tree.
  • Figure 2: The program bst; the rest of the rules are graphically depicted in Figure \ref{['fig:bst-prog2']}.
  • Figure 3: Remaining rules of program bst.
  • Figure 4: Measured runtime per operation on degenerated trees.
  • Figure 5: Measured averaged runtime for an insertion, followed by a search and deletion, on balanced trees.

Theorems & Definitions (1)

  • Claim 1