Giter Club home page Giter Club logo

observerpattern's Introduction

PURPOSE: Implement Observer pattern on Binary Search Tree and update value of node using pattern. 

Description: Here total 3 trees are available. First One is original tree which is populated by reading the file and inserting the value in the tree, as value insert into the main tree backup-1 and backup-2 tree also inserted as they are observer of main tree. 
As per second argument value if it is even than, in main tree each node is updated by addition of that value. With that as per backup-1 is observer for even value it is also will be updated. For odd argument value main and backup-2 tree will be updated via observer. 

FILES: Driver.java, BST.java, FileProcessor.java, Node.java, ObserverI.java, SubjectI.java, BSTBuilder.java, EvenFilterImpl.java, OddEvenFilterI.java, OddFilterImpl.java

SAMPLE OUTPUT: Depends upon Input, However for input file:
10
30
25
5
3
4
6
7
35

Output:
3 4 5 6 7 10 25 30 35 
3 4 5 6 7 10 25 30 35 
3 4 5 6 7 10 25 30 35 
The sum of all the B-Numbers is: 125
The sum of all the B-Numbers is: 125
The sum of all the B-Numbers is: 125
8 9 10 11 12 15 30 35 45 
3 4 5 6 7 10 25 30 35 
8 9 10 11 12 15 30 35 45 
The sum of all the B-Numbers is: 175
The sum of all the B-Numbers is: 125
The sum of all the B-Numbers is: 175


COMPILE THE CODE: ant -buildfile src/build.xml all

RUN THE CODE: ant -buildfile src/build.xml run -Darg0=input.txt -Darg1=5 <Value to be add into each number like first element 3+5=8>

CHOICE OF DATA STRUCTURE: HashMap
->Complexity of Data Structure:
		
Space	O(n)
Search	O(1)
Insert	O(1) [Amortized]
Delete	O(1)
->Hashmap is unsynchorized key value pair storing of objects.

observerpattern's People

Contributors

vishvas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.