Methodological Instructions
Theme: Algorithms on graphs
Aim: Implementation of search algorithms on graphs to solve the practical tasks
Lesson objective: Implementation of binary search tree (BST) graph to solve the practical task
Assessment criteria
Knowledge
· Know what is a binary search tree (BST) graph
Comprehension
· Understand the structure of BST graph
Application
· Implement BST graph algorithm
Language objectives
Learners able to …
• State what is BST
• Describe the purpose of BST graph and its application in Computer Science
Vocabulary and terminology specific to the subject:
binary search tree graph, nodes, path, root, vertices, edge
Useful expressions for dialogs and letters:
Well, in binary search tree graph there are … .
For example, every vertex has its own position and could be connected by edges.
Obviously, the path in BST graph has … .
Theory
Binary Search Tree
A Binary Search Tree is a binary tree with a search property where elements in
the left sub-tree are less than the root and elements in the right sub-tree are
greater than the root.

Walking (Traversing) a Binary Search Tree
There can be 3 types of tree traversals in a binary tree as below.
Pre-Order
traversal
In this traversal the traversal happens in the following order.
For
the binary search tree, displayed above the Pre-Order traversal would be as
follows.

The C# implementation for the same is as follows.
public void PreOrder_Rec (TNode root)
{
if (root != null)
{
Console.Write(root.Data +" ");
PreOrder_Rec(root.Left);
PreOrder_Rec(root.Right);
}
}
In-Order traversal
In this traversal the traversal happens in following order:
For
the binary search tree, displayed above the In-Order traversal would be as
follows.

The C# implementation for that is as follows.
public void InOrder_Rec(TNode root)
{
if (root != null)
{
InOrder_Rec(root.Left);
Console.Write(root.Data +" ");
InOrder_Rec(root.Right);
}
}
Post-Order traversal
In this traversal the traversal happens in the following order:
For
the binary search tree, displayed above the Post-Order traversal would be as
follows.

The C# implementation for that is as follows:
public void PostOrder_Rec(TNode root)
{
if (root != null)
{
PostOrder_Rec(root.Left);
PostOrder_Rec(root.Right);
Console.Write(root.Data +" ");
}
}
Important Notes
П. Questions for self-assessment.
What is the BST graph in Computer Science?
How to perform traversal in BST graph?
Visual Aids and Materials links.
2. https://www.c-sharpcorner.com/UploadFile/19b1bd/binarysearchtreewalkstraversal-implementation-using-C-Sharp/
3. https://en.wikibooks.org/wiki/A-level_Computing_2009/AQA/Problem_Solving,_Programming,_Operating_Systems,_Databases_and_Networking/Programming_Concepts/Tree_traversal_algorithms_for_a_binary_tree
Students' Practical Activities:
Students must be able:
· perform traversal for BST graph in 3 different ways
Скачано с www.znanio.ru
Материалы на данной страницы взяты из открытых источников либо размещены пользователем в соответствии с договором-офертой сайта. Вы можете сообщить о нарушении.