Monday, March 4, 2013

Data Structures - For my Ninth Grader – Part 2




List: Have you ever made a shopping list or list of tasks which you want to do today. If your answer is YES then you have firsthand experience of List. 



In above To Do list each item holds a relative position with respect to other. So list is a collection of items where each item holds a relative position with respect to the others. More over one cannot choose and pick any item irrespective of position of that item within list but also insert or delete an item at any position in the list. It is true that insertion and deletion of any item affect position of each item in list.

One can do following operations on a list:

  1. 1.      Add a specific item at end of list >>> append (item)
    2.      Add an item at specific position in the list >>> insert (item, position)
    3.      Remove a specific item from the list >>> remove (item)
    4.      Remove an item from specific position >>> remove (position)
    5.      Find out position of an item in the list >>>  index (item)
    6.      Search an item in the list >>> search (item)
    7.      Remove an item from the given position >>>  remove (position)
    8.      Remove an item from the list >>> remove (item)
    9.      Find out if list is empty >>> isEmpty()
    10.  Find out number of items in the list >>> length()

Size of list can grow up to any length there is no limit. A list can have duplicate items.

Linked List: Linked list is a special type of list in which one can move forward only.


Circular Linked List:  It is special kind of linked list in which one can move from last item to first item.




Doubly Linked List: In Doubly Linked List, one can move forward as well as backward.
 


No comments:

Post a Comment