GithubHelp home page GithubHelp logo

assignment's Introduction

Assignment

Algorithm Insertion

Input: data, the data to be inserted and header, the pointer to the header node
Output: bag with new data inserted.
Data Structure: Linked list representation of multiset.

1. ptr=header
2. while(ptr→link!=NULL) //traverse till the last node
    2.1 ptr=ptr→link
    2.2 if(ptr→data=data) // checking if a copy of the data already exist
        1. go to step 10
    2.3 endif
3. endwhile
4. new=GETNODE(NODE)// Creating a new node
5. new→data=data// entering data
6. new→count=1//setting count as 1
7. new→link=NULL
7. ptr→link=new// inserting the node at the last position
9. go to 11
10. ptr→count=ptr→count+1
11. Stop

Algorithm Deletion

Input: data, the item to be deleted, header, the pointer to the header node. Output: bag with data deleted. Data Structure: Linked list representation of multiset

1. flag=0
2. ptr=header
3. if(ptr=NULL)
        3.1 print “The Bag is empty”
4. else
    4.1. while(ptr→link!=NULL)
        4.1.1. ptr1=ptr
        4.1.2. ptr=ptr→link
        4.1.3. if(ptr→data=data)
            4.1.3.1. flag=1
            4.1.3.2. go to 4.1.5.1
        4.1.4. endif
        4.1.5. if(flag=0)
            4.1.4.1. print “ data is not present in bag”
        4.1.6. else
            4.1.6.1. ptr→count=ptr→count-1
            4.1.6.2. if(ptr→count=0)
                1. ptr1=ptr→link
            4.1.6.3. endif
        4.1.7. endif
    4.2. endwhile
5. endif
6. stop

Algorithm Deletion

Input: header, the pointer to the header node. Output: display the multiset Data Structure: Linked list representation of multiset

1. ptr=header→link
2. if(ptr=NULL)
        1.1 print “The bag is empty”
3. else
    3.1. while(ptr!=NULL)
        3.1.1. print “count,ptr→data”
    3.2. endwhile
4. endif
5. stop

assignment's People

Contributors

sarathraveendran6 avatar sidharthsandeep 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.