Wednesday, March 20, 2013

Data Structures - For my Ninth Grader – Part 3

Data Structures - For my Ninth Grader – Part 2

Data Structures - For my Ninth Grader – Part 1



Set: Let’s keep all of the members of from49ers (http://www.49ers.com/team/roster.html) in a room. No two members are identical, everyone is unique and they have reason to be in room ( after all they are on 49ers roster). In the room each member can do whatever each wish; each member can exist without any specific order.  You have a Set.
 




Set is a data structure that can store certain values, without any particular order, and no repeated values.

One can do following operations on a set:

  1. Add a specific item to the set >>> add (item)
  2. Remove a specific item from the set >>> remove (item)
  3. Find out if specific item is in set >>> IsElementOf (item)
  4. Find out if list is set >>> isEmpty()
  5. Find out number of items in the set >>> size()
  6. How many number of items a set can hold >>> capacity()
  7. Get an arbitrary element from a set >>> pop()
  8. Delete all elements from a set >>> clear()

 
    Map: Lets’ write each telephone number in ordered fashion in notebook for city of Sunnyvale (http://sunnyvale.ca.gov). In front of each telephone number write name of owner and address. Each telephone number is unique. If someone knows a telephone number, he can find that who owns this telephone number. In this case Telephone number is Key and telephone owner name and address is value. It is also possible that a person can own multiple telephone numbers in that case his name will appear at multiple places in your notebook. This note book represents a map.






      A map is an ordered data structure in which collections of unique key and collections of values are stored where each key is associated with one value. The operation of finding the value is called lookup.

       One can do following operations on a map:


  1. Add a specific item with specific key to a map >>> add (key, value)
  2. Remove an item associated with a specific key from a map >>> remove (key)
  3. Find out the item associated with a key in a map >>> lookup (key)
  4. Replace the value in one of the (key,value) pairs that are already in the collection >>> reassign(key, value)
  5. Delete all elements from a map >>> clear()
       Map is an ordered data structure. This means that elements are maintained in sequence, the ordering determined by key values


No comments:

Post a Comment