Assignment#1
Assignment#1
Assignment#1
ID#16120
DATA STRUCTURE AND ALGORITHIMS ASSIGNMENT#1 SUBMITTED TO: SIR ASIM IFTIKHAR DATE: 3rd Feb/14
LINEAR:
Linear data structures follow sequential order. Linear data structures are following: 1)Array. 2)Linked list. 3)Stack. 4)Queus.
ARRAYS:
An array is a data structure that contains a group of elements. These elements are of same data type such as integer or string. Arrays are used to organize data so that related set of values can easliy be sorted or serached. Arrays have some adevantages as well as some disadvantages which are as follows:
ADVANTAGES:
Some advantages of array are: 1) Multiple data of same type can be represented by using only one single name. 2) Capable of storing many elements at a time. 3) Data accessing is faster, user can access any data item efficiently just by specifying the index of that item. 4) Arrays are simple to understand and use. 5) It can be used to implement other data structures such as linked list, stack, graph etc.
DISADVANTAGES:
Disadvantages of arrays are:
1) The memory which is allocated in array cannot be increased or decreased i.e, array have fixed size. 2) Insertion and deletion is very difficult and time consuming in array because arrays are stored in consecutive memory location. 3) There is a chance of memory wastage in array. 4) Predetermining the size of array is must.
LINKED LIST:
The linked list is a finite sequence of nodeseach of which contains a pointer field pointing to the next node. Elemnts are organized sequentially in linked list data structure. Advantages and disadvantages of linked list data structure are as follows:
ADVANTAGES:
Advantages of linked list are as follows: 1) Insertions and deletions can be done easily. 2) User can use more than one data type in linked list data strucuture. 3) Its space is not wasted as we can get space according to our requirments. 4) It can be extended or reduced according to our requirments. 5) Movements of elements is not required while deleting or inserting any element. 6) Its size is not fixed. 7) Elements may or may not be stored in consecutive memory.
DISADVANTAGES:
1) 2) 3) 4) 5) It requires more space as pointers are stored with separate information. Sorting of elements in not easy. Access of elements is difficult. Linked list cannot be accessed randomly. User cannot traverse elements from the last.
STACK:
A stack is an ordered list in which insertions and deletions take place at one end I,e. from the top. Stack is First In Last Out data structure. It is ordered list of same data type. Some of the advantages and disadvantages of stack are follows:
ADVANTAGES:
Advantages of stack are as follows: 1) Stack allows user to store data on hard disk. 2) It allows user to make proper use of the space available. 3) It allows user to relate data so that user can actually use it.
DISADVANTAGES:
Some of the disadvantages of stack are as follows: 1) It is inflexible. 2) Lack of scability.
QUEUE:
Queue is a particular kind of abstract data structure in which the entities in collection are kept in order. It follows FIFO system i.e, first in first out. Advantages and disadvantages of queue are as follows:
ADVANTAGES:
Advantages of queue data structure are as following: 1) Queses are flexible. 2) Allows user to handle multiple tasks. 3) Insertions and deletions can take place easily in queue data structure. 4) Related to ordered list.
DISADVANTAGES:
Disadvantages of queue data structure are as following: 1) Traversing is difficult in queue data structure.
2) Queue has fixed entry and fixed exit point. 3) Less efficient and slow.
NON-LINEAR:
Non-linear data structure does not follow sequential order. Basically,it describes the relationship or follow heirarchy. Non-linear are of two types which are: 1) Trees. 2) Graphs.
Trees:
A type of data structure in which each element is attached to one or more element directly beneath it. A tree is finite set on one or more nodes. Tree data structure have some advantages as well as some disadvantges which are described as follows.
ADVANTAGES:
Here are some advantages of trees data structure: 1) Searching of elements in trees in faster and easier. 2) Capable of representing all lind of pbject heirarchies. 3) Most powerful and advanced data structure. 4) Provides fast look up. 5) Easy accomodation of creation and deletion of files and folders.
DISADVANTAGES:
Some of the disadvantages of trees are as following: 1) Access of elements is difficult. 2) Have fixed size.
GRAPHS:
Graph in data structure is a collection of nodes called vertices, and the connection between them is called edges. Graph data structure have some advantages and disadvantages which are following:
ADVANTAGES:
Some of the advantages of graph data structure are: 1) Access to any node os easy. 2) There is no time complexity. 3) The object/pointer in graph is more efficient than any other data structure. 4) Simple and easy to understand.
DISADVANTAGES:
There are some disadvantages of graph data structure which are: 1) Cannot be extended to accommodate vertices or set of edges. 2) Graph nmust be known statically at the time of compilation. 3) Compilation in graphs in not really effficient.
CONCLUSION:
Hence, all data structures are efficient to use but at the same time data structures have some disadvantages