1. BuilderVisitor 2. XMLMetadataVisitor 3. ProcessMetadataVisitor 4. FolderRenameVisitor 5. ComparerVisitor 6. SyncerVisitor 7. XMLWriterVisitor.

Slides:



Advertisements
Similar presentations
Chapter6 LISTS AND STRINGS. Outline 1. List Specifications 2. List Implementations (a) Class Templates (b) Contiguous (c) Simply Linked (d) Simply Linked.
Advertisements

Ceng-112 Data Structures I Chapter 5 Queues.
The Singleton Pattern II Recursive Linked Structures.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
Binary Trees. DCS – SWC 2 Binary Trees Sets and Maps in Java are also available in tree-based implementations A Tree is – in this context – a data structure.
Searching Kruse and Ryba Ch and 9.6. Problem: Search We are given a list of records. Each record has an associated key. Give efficient algorithm.
DictionaryADT and Trees. Overview What is the DictionaryADT? What are trees? Implementing DictionaryADT with binary trees Balanced trees DictionaryADT.
DISCUSSION OF SOME QUESTIONS ON PRELIM 2 Lecture 23 CS2110 – Spring 2015.
C++ Plus Data Structures
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
B+ Trees Similar to B trees, with a few slight differences
Searching Arrays Linear search Binary search small arrays
A Binary Search Tree Implementation Chapter 25 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Searching Chapter Chapter Contents The Problem Searching an Unsorted Array Iterative Sequential Search Recursive Sequential Search Efficiency of.
E.G.M. PetrakisB-trees1 Multiway Search Tree (MST)  Generalization of BSTs  Suitable for disk  MST of order n:  Each node has n or fewer sub-trees.
1. BuilderVisitor 2. XMLMetadataVisitor 3. ProcessMetadataVisitor 4. FolderRenameVisitor 5. ComparerVisitor 6. SyncerVisitor 7. XMLWriterVisitor.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
Computer Architecture B-tree construction & Traversal YongSoo Bae Room 236, Engineering Building [Project 1]
1 Trees Tree nomenclature Implementation strategies Traversals –Depth-first –Breadth-first Implementing binary search trees.
AITI Lecture 20 Trees, Binary Search Trees Adapted from MIT Course 1.00 Spring 2003 Lecture 28 and Tutorial Note 10 (Teachers: Please do not erase the.
Data Structures Using C++1 Search Algorithms Sequential Search (Linear Search) Binary Search.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 19: Searching and Sorting Algorithms.
Binary Trees Chapter Definition And Application Of Binary Trees Binary tree: a nonlinear linked list in which each node may point to 0, 1, or two.
Multi-way Trees. M-way trees So far we have discussed binary trees only. In this lecture, we go over another type of tree called m- way trees or trees.
Chapter 7: Sorting Algorithms Insertion Sort. Sorting Algorithms  Insertion Sort  Shell Sort  Heap Sort  Merge Sort  Quick Sort 2.
Data Structures Using C++ 2E Chapter 10 Sorting Algorithms.
1 Chapter 10 Trees. 2 Definition of Tree A tree is a set of linked nodes, such that there is one and only one path from a unique node (called the root.
CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Outline Binary Trees Binary Search Tree Treaps. Binary Trees The empty set (null) is a binary tree A single node is a binary tree A node has a left child.
1 C++ Plus Data Structures Nell Dale Chapter 10 Sorting and Searching Algorithms Slides by Sylvia Sorkin, Community College of Baltimore County - Essex.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Modified for use at Midwestern State University Chapter.
Objectives At the end of the class, students are expected to be able to do the following: Understand the searching technique concept and the purpose of.
1 Chapter 13-1 Applied Arrays: Lists and Strings Dale/Weems.
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 15 Other Data Structures Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
 MergeSort is a sorting algorithm which is more on the advanced end.  It is very fast, but unfortunately uses up a lot of memory due to the recursions.
LINKED LISTS Midwestern State University CMPS 1053 Dr. Ranette Halverson 1.
AVL Trees and Heaps. AVL Trees So far balancing the tree was done globally Basically every node was involved in the balance operation Tree balancing can.
Copyright © 2012 Pearson Education, Inc. Chapter 20: Binary Trees.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 20: Binary Trees.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Data Structures Arrays and Lists Part 2 More List Operations.
Chapter 9 Recursion © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Linked List.  Is a series of connected nodes, where each node is a data structure with data and pointer(s) Advantages over array implementation  Can.
2 Binary Heaps What if we’re mostly concerned with finding the most relevant data?  A binary heap is a binary tree (2 or fewer subtrees for each node)
Course: Programming II - Abstract Data Types HeapsSlide Number 1 The ADT Heap So far we have seen the following sorting types : 1) Linked List sort by.
8/3/2007CMSC 341 BTrees1 CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 20: Binary Trees.
11 Graph Search Algorithms. 2 What parts of the graph are reachable from a given vertex ?
Topic 2: binary Trees COMP2003J: Data Structures and Algorithms 2
Lesson Objectives Aims Understand the following “standard algorithms”:
Data Structures Using C++ 2E
External Methods Chapter 15 (continued)
Chapter 20: Binary Trees.
Binary Trees.
Data Structures and Database Applications Binary Trees in C#
Chapter 21: Binary Trees.
Searching.
File Handling Programming Guides.
Find in a linked list? first last 7  4  3  8 NULL
B- Trees D. Frey with apologies to Tom Anastasio
Database Systems Instructor Name: Lecture-3.
Binary Search Trees.
B- Trees D. Frey with apologies to Tom Anastasio
Multiway Search Tree (MST)
Data Structures & Algorithms
Binary Search Trees.
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
A Binary Search Tree Implementation
Amir Kamil 8/8/02 1 B+ Trees Similar to B trees, with a few slight differences All data is stored at the leaf nodes (leaf pages); all other nodes (index.
Presentation transcript:

1. BuilderVisitor 2. XMLMetadataVisitor 3. ProcessMetadataVisitor 4. FolderRenameVisitor 5. ComparerVisitor 6. SyncerVisitor 7. XMLWriterVisitor

1. BuilderVisitor  Builds the merged tree. 2. ComparerVisitor  Compares and updates the state of each node. 3. SyncerVisitor  Takes the updated state of each node and performs an action to keep them synchronized.

BuilderVisitor

Traverse and build or populate tree for “C:\Users\Wysie\Desktop\A” RootCompareObject string[] paths paths[0] = “C:\Users\Wysie\Desktop\A” paths[1] = “C:\Users\Wysie\Desktop\B” paths[2] = “C:\Users\Wysie\Desktop\C” FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 0; long[2] = 0; FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 0; long[2] = 0; FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ZXCVB”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 30000; long[1] = 0; long[2] = 0; FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 0; Since “A” is the first folder to be build, all the FileCompareObjects or FolderCompareObjects will be created. Index 0: C:\Users\Wysie\Desktop\A Index 1: C:\Users\Wysie\Desktop\B Index 2: C:\Users\Wysie\Desktop\C Build FolderCompareObject with name “School Work”, and populate information at index 0. Now, traverse the contents of “School Work” and build new objects. In this case, build “Final.pdf” and “Proposal.docx” and populate index 0. Nothing else to build, so we return all the way back to RootCompareObject. Now, we build “CueSheet.docx” and populate information at index 0. Finally, we build “Results.txt” and populate the information at index 0.

Traverse and build or populate tree for “C:\Users\Wysie\Desktop\B” RootCompareObject string[] paths paths[0] = “C:\Users\Wysie\Desktop\A” paths[1] = “C:\Users\Wysie\Desktop\B” paths[2] = “C:\Users\Wysie\Desktop\C” FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 0; long[2] = 0; FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 0; long[2] = 0; FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ZXCVB”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 30000; long[1] = 0; long[2] = 0; FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 0; Index 0: C:\Users\Wysie\Desktop\A Index 1: C:\Users\Wysie\Desktop\B Index 2: C:\Users\Wysie\Desktop\C Since “School Work” does not exist in “B”, the entire portion remains unchanged. “CueSheet.docx” is found in “B”. We now populate index 1 of “CueSheet.docx” with information. FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = “MNBVC”; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 88888; long[2] = 0; FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = “VVBBB”; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 90000; long[2] = 0; “Results.txt” is also found in “B”. We now populate index 1 of “Results.txt” with information.

FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = “VVBBB”; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 90000; long[2] = 0; FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = “MNBVC”; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 88888; long[2] = 0; Traverse and build or populate tree for “C:\Users\Wysie\Desktop\C” RootCompareObject string[] paths paths[0] = “C:\Users\Wysie\Desktop\A” paths[1] = “C:\Users\Wysie\Desktop\B” paths[2] = “C:\Users\Wysie\Desktop\C” FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ZXCVB”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 30000; long[1] = 0; long[2] = 0; FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 0; Index 0: C:\Users\Wysie\Desktop\A Index 1: C:\Users\Wysie\Desktop\B Index 2: C:\Users\Wysie\Desktop\C “School Work” exists in “C”. Populate index 2 in “C”. FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true “Final.pdf” does not exist. However, “Proposal.docx” exists. Populate at index 2. FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = “DFGHJK”; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 10000;

 There are many other attributes that are left out, such as priority, new name, creation time, among many others. For a more detailed explanation, please take a look at the source code comments.

ComparerVisitor

FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = “DFGHJK”; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 10000; FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = “VVBBB”; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 90000; long[2] = 0; FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = “MNBVC”; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 88888; long[2] = 0; ComparerVisitor will now visit the tree. RootCompareObject string[] paths paths[0] = “C:\Users\Wysie\Desktop\A” paths[1] = “C:\Users\Wysie\Desktop\B” paths[2] = “C:\Users\Wysie\Desktop\C” FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ZXCVB”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 30000; long[1] = 0; long[2] = 0; Index 0: C:\Users\Wysie\Desktop\A Index 1: C:\Users\Wysie\Desktop\B Index 2: C:\Users\Wysie\Desktop\C FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = “MNBVC”; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 88888; long[2] = 0; srcPosition = 0 FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = “VVBBB”; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 90000; long[2] = 0; srcPosition = 1 FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true srcPosition = 0 FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ZXCVB”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 30000; long[1] = 0; long[2] = 0; srcPosition = 0 FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = “ASDFG”; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 10000; srcPosition = 0 It will first visit “School Work”. Since it exists in index 0 and index 2, but not in index 1, the algorithm will set source position to 0. Now, it will traverse the contents of “School Work”. For “Final.pdf”, since it only exists in index 0, source position will again be set to 0. For “Proposal.docx”, it exists in 0 and 2, but not in 1. Comparing the hash of index 0 and 2 shows that they are identical. Thus, source position will be set to 0. It will now visit “CueSheet.docx”. Since it exists in index 0 and 1 but not in 2, comparison will be done between 0 and 1. Based on the last modified date, the one at index 0 is more updated then the one at index 1. Thus, source position will be set to 0. Finally, “Results.txt” is visited. Again, it exists in index 0 and 1. This time round, the one at index 1 is found to be more updated. Source position is 1.

 The purpose of source position is for SyncerVisitor to find out which file to propagate.  In actual fact, there is another array called priority. All files which are determined to be equal (same hash if create/update, same new name if rename, or file does not exist if delete) are given equal priority.  During actual synchronization, only lower priority indexes than that of the source position will be affected. This is to prevent redundant file or folder changes.

SyncerVisitor

FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true srcPosition = 0 FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = false string[] hash; hash[0] = “ZXCVB”; hash[1] = null; hash[2] = null; long[] lastModified; long[0] = 30000; long[1] = 0; long[2] = 0; srcPosition = 0 FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = false exists[2] = true string[] hash; hash[0] = “ASDFG”; hash[1] = null; hash[2] = “ASDFG”; long[] lastModified; long[0] = 10000; long[1] = 0; long[2] = 10000; srcPosition = 0 FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “AAAAA”; hash[1] = “VVBBB”; hash[2] = null; long[] lastModified; long[0] = 70000; long[1] = 90000; long[2] = 0; srcPosition = 1 FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = false string[] hash; hash[0] = “QWERTY”; hash[1] = “MNBVC”; hash[2] = null; long[] lastModified; long[0] = 99999; long[1] = 88888; long[2] = 0; srcPosition = 0 SyncerVisitor will now visit the tree. RootCompareObject string[] paths paths[0] = “C:\Users\Wysie\Desktop\A” paths[1] = “C:\Users\Wysie\Desktop\B” paths[2] = “C:\Users\Wysie\Desktop\C” Index 0: C:\Users\Wysie\Desktop\A Index 1: C:\Users\Wysie\Desktop\B Index 2: C:\Users\Wysie\Desktop\C It will first visit “School Work”, determine the source position, and then create a folder when necessary. The state of the node will then be updated. FolderCompareObject name = “School Work” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = true srcPosition = 0 FileCompareObject name = “Final.pdf” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = true string[] hash; hash[0] = “ZXCVB”; hash[1] = “ZXCVB”;; hash[2] = “ZXCVB”;; long[] lastModified; long[0] = 30000; long[1] = 30000; long[2] = 30000; srcPosition = 0 Next it will visit “Final.pdf”. Since source position is 0, it will be copied over to the other positions, and the state of the node will then be updated. Then, it will visit “Proposal.docx”. Since source position is 0, but index 2 is determined to be equal, only 1 will be updated. FileCompareObject name = “Proposal.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = true string[] hash; hash[0] = “ASDFG”; hash[1] = “ASDFG”; hash[2] = “ASDFG”; long[] lastModified; long[0] = 10000; long[1] = 10000; long[2] = 10000; srcPosition = 0 The next node to be visited is “CueSheet.docx”. Since the source position is 0, and it is the most updated, it will propagate to the other 2 locations. FileCompareObject name = “CueSheet.docx” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = true string[] hash; hash[0] = “QWERTY”; hash[1] = “QWERTY”; hash[2] = “QWERTY”; long[] lastModified; long[0] = 99999; long[1] = 99999; long[2] = 99999; srcPosition = 0 Finally, “Results.txt” will be visited. Since the source position is 1, and it is more updated then the rest, it will propagate to the other nodes. FileCompareObject name = “Results.txt” numOfPaths = 3 bool[] exists; exists[0] = true exists[1] = true exists[2] = true string[] hash; hash[0] = “VVBBB”; hash[1] = “VVBBB”; hash[2] = “VVBBB”; long[] lastModified; long[0] = 90000; long[1] = 90000; long[2] = 90000; srcPosition = 1 With that, all the files and folders are now synchronized.

 As stated earlier, a priority array in each node is used to determine if a file is actually copied over.

 We hope this simple presentation will give you a good overview of how the visitor pattern, and in particular, how our merged tree, works.  Many other functions and visitors were not explained, please look at the detailed comments in the source code, as well as the developer guide, if you are interested.  Traversing the tree can be pre, post, or level- order traversal, depending on what is needed.