Friday, January 6, 2012

algorithms & data structures

Understanding how to choose the best algorithm or data structure for a particular task is one of the keys to writing high-performance software
If you start with the wrong algorithm, all the micro-level tuning in the world won't produce optimal results.


  • What is a data structure? What are the types of data structures?

Data structures are used to store data in a computer in an organized fashion.


  • Different types of data structures are:


  1. Arrays: A set of homogeneous values
  2. Records: A set of fields, where each field consists of data belongs to one data type.
  3. Stack- Works in first in last out order. The element inserted first in stack is removed last.
  4. Queue- First in First out order. The element inserted first is removed first.
  5. Linked list- Stored data in a linear fashion.
  6. Trees- Stores data in a non linear fashion with one root node and sub nodes.A data structure where the data is organized in a hierarchical structure.This type of data structure follows the sorted order of insertion, deletion and modification of data items




  • Define a linear and non linear data structure

Linear data
Linked list is an example of linear data storage or structure.
Linked list stores data in an organized a linear fashion. They store data in the form of a list.
A linear data structure traverses the data elements sequentially, in which only one data element can directly be reached.
Ex: Arrays, Linked Lists

Non Linear data structure
Tree data structure is an example of a non linear data structure.
A tree has one node called as root node that is the starting point that holds data and links to other nodes.
Every data item is attached to several other data items in a way that is specific for reflecting relationships.
The data items are not arranged in a sequential structure.
Ex: Trees, Graphs

data structure is a way of organizing data that considers how items are stored and their relationship between them


Reference:
http://java.sun.com/docs/books/performance/1st_edition/html/JPAlgorithms.fm.html
http://www.java2s.com/Code/Java/Collections-Data-Structure/CatalogCollections-Data-Structure.htm
http://www.careerride.com/Data-Structure-Interview-Questions.aspx
http://globalguideline.com/interview_questions/Questions.php?sc=Data_Structures_Interview_Questions_and_Answers_&page=1

No comments:

Post a Comment