Friday, March 13, 2009

Data structure
In computer science, a graph is a kind of data structure, specifically an abstract data type (ADT), that consists of a set of nodes (also called vertices) and a set of edges that establish relationships (connections) between the nodes. The graph ADT follows directly from the graph concept from mathematics.
Informally, G=(V,E) consists of vertices, the elements of V, which are connected by edges, the elements of E. Formally, a graph, G, is defined as an ordered pair, G=(V,E), where V is a set (usually finite) and E is a set consisting of two element subsets of V.

Two main data structures
1.adjacency list- is implemented by representing each node as a data structure that contains a list of all adjacent nodes.
2.adjacency matrix, in which the rows and columns of a two-dimensional array represent source and destination vertices and entries in the array indicate whether an edge exists between the vertices.

TREES
In computer science, a tree is a widely-used data structure that emulates a hierarchical tree structure with a set of linked nodes. It is an acyclic connected graph where each node has a set of zero or more children nodes, and at most one parent node

DIFFERENT KINDS OF TREES
1. B-tree
2. Dancing tree
3. kd-tree
4. Quadtree
5. R-tree
6. Radix tree
7. T-tree

Sorting Algorithm

In computer science and mathematics, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most used orders are numerical order and lexicographical order. Efficient sorting is important to optimizing the use of other algorithms (such as search and merge algorithms) that require sorted lists to work correctly; it is also often useful for canonicalizing data and for producing human-readable output.

Different Kinds of Sorting Algorithm
 Bubble sort - O(n2)
 Cocktail sort (bidirectional bubble sort) - O(n2)
 Insertion sort - O(n2)
 Bucket sort - O(n); requires O(n) extra memory
 Heap sort
 Counting sort - O(n+k); requires O(n+k) extra memory
 Merge sort - O(n log n); requires O(n) extra memory
 Binary tree sort - O(n log n); requires O(n) extra memory
 Radix sort - O(nk); requires O(n) extra space

1. Bubble sort - is the most straightforward and simplistic method of sorting data that could actually be considered for real world use.
2. Cocktail sort - is a stable sorting algorithm that varies from bubble sort in that instead of repeatedly passing through the list from top to bottom, it passes alternately from top to bottom and then from bottom to top.
3. Insertion sort - is a simple sort algorithm in which the sorted array (or list) is built one entry at a time.
4. Bucket sort - is a sort algorithm that works by partitioning an array into a finite number of buckets and then sorting each bucket. It is a generalization of pigeonhole sort.
5. Heap sort - is a comparison-based sorting algorithm, and is part of the selection sort family.
6. Counting sort - is a sorting algorithm which takes advantage of knowing the maximum value within the array to be sorted.
7. Merge sort - is a sort algorithm for rearranging lists (or any other data structure that can only be accessed sequentially, e.g. file streams) into a specified order.
8. Binary tree sort - is a binary tree where every node has a value, every node's left sub tree has values less than the node's value, and every right sub tree has values greater.

No comments:

Post a Comment