Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Functional Specifications Tree Basics Traversal Techniques Wire Fame User’s Conceptual Model Designer’s model Flow of Control The Tree Basics Tree is a non-linear, two-dimensional data structure. It is called a tree because of its shape when represented Like genealogists draw family trees, computer scientists draw trees from the root node down - unlike nature After vectors (arrays) and lists, probably the most commonly encountered data structure used in computer algorithms Used frequently in everyday life, egs: family trees, organization of sports tournaments, organizational charts, parse tree of language sentence. Tree Terms A tree is a non-empty collection of vertices (nodes) that can have a name and other associated data to be stored and edges that connect between two vertices. Root node: first node in the tree Parent node: node that points to other nodes Child node: node pointed to by parent Leaf node: node with no children Path: is the list of nodes connected by the edges - the defining property of a tree is that there is exactly one path between the root and each of the other nodes in the tree. Binary tree: tree whose nodes all contain two links (to none, one or two children). Subtree: portion of the tree structure usually referred to as left or right subtree Depth: the longest path from the root to any node Forest: a set of trees! Basically all genealogical terms (siblings, descendants, etc.) are used with computer tree structures too. Binary Tree Is a finite set of nodes that is either empty of consists of a root and two disjoint binary trees calls a left subtree and a right subtree The Binary Search Tree The binary search tree: the most common form of binary tree, is created by inserting items according to some order Tree traversal Definition: A technique for processing the nodes of a tree in some order. in-order traversal, postorder traversal, tree traversal, level-order traversal. What I've just called ``scanning through'' a tree is actually called traversing a tree. General Definition: to traverse a data structure is to process, however you like, every node in the data structure exactly once. Note: You may ``pass through'' a node as many times as you like but you must only process the node once. E.g. we can talk about ``traversing a list'', which means going through the list and processing every node once. We had a special name for this: map. For a specific data structure, we talk about the different orders in which it might be traversed. For a list there are two common traversal orders: first-to-last (the most common) and last-to-first. The general recursive pattern for traversing a (non-empty) binary tree is this: At node N you must do these three things: (L) recursively traverse its left subtree. When this step is finished you are back at N again. (R) recursively traverse its right subtree. When this step is finished you are back at N again. (N) Actually process N itself. We may do these things in any order and still have a legitimate traversal. If we do (L) before (R), we call it left-to-right traversal, otherwise we call it right-to-left traversal. Pre-Order Traversal do (N) before anything else. Post-Order Traversal do (N) after everything else. In-Order, or Infix Order, Traversal do (N) in between the two subtrees. E.g. let us look at what order the nodes will get processed given this tree: Using Left-To-Right traversal: WireFrame User’s Conceptual Model What is all about – here we will talk about concepts of tress and traversals New Tree User selects an option New Tree to start a tree. The first number entered becomes the root of the tree. The subsequent numbers entered become its children . There is no limit on the size of tree (Hardware of user is only constraint of limit ) Load A pre-saved tree can be loaded into the program to view it. Only one tree can be loaded as the user can save one tree only. Add a node User selects the option “Add” to add a new node. On clicking the Add option the user gets a prompt to enter a number of his choice (The new number should follow the rules listed below) Rules for a valid input node The value entered should be an Integer (No alphabets e.g. a,b,t,z ;No Alpha numeric e.g. a12,we22 or r3r And No Special Characters eg.*,$,&) The number entered should be an integer (No Real or exponential numbers are allowed e.g. 10.1 , 10e10),number should be in the range?? To??. Numbers should not be repeated. Delete a node User selects the option “Delete” to delete a node from tree.On selectin the option the user gets a prompt to enter a number(node) to be deleted . Rules for deleting a node The selected number (node) should be a number existing in the tree. Number once deleted can be repeated again. All the numbers follow the rules defined for a valid number On selecting an non-existing number the user get a prompt. Find User can check for existence of an number by selecting an option “Find” This gives the user a prompt to enter a number. User gets a keyboard shortcut to perform the operations. Rules for selecting a number to Find The selected number should be a member of tree. The input to the prompt should abide to the rules of Valid input.. Multiple searches are allowed on a node. Save User can save the latest tree he is viewing. Only one tree can be saved. The tree gets a default name specified by the program. o The saved tree can be viewed only through the applet. o If Save operation can be committed on a tree with changes done to it. o Save can be done to commit changes done to pre-saved tree. Clear User can use the option Clear to tree loaded to the applet. It should be used to start a New tree or load a saved tree. Traversal Menu Pre-Order, In-Order and Post-Order Traversal. User can traverse in different orders using options Pre-Order, In-Order and PostOrder from menu. Designer’s Model User inputs different values and selects different options to traverse the tree. Flow of control User Selects from menu to either Travers or open Help The user get an option to open new or load a saved tree. The Menu of IN/PRE/POST ORDER Traversal is given to user. The user can start adding new nodes. User can delete a node from tree. The user can find a node The user can save the tree. User can clear the tree ,and the control goes back to option to either load or create new tree From here WE will describe the working using screen shots.. 1. 2. 3. 4. 5. Load/New Tree Add/Delete a node Save/Clear a tree. Help Traversing(IN/PRE/POST ORDER)