Custom Search

Wednesday, March 20, 2013

Data Structure


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:-
Stack- Works in first in last out order. The element inserted first in stack is removed last.
Queue- First in First out order. The element inserted first is removed first.
Linked list- Stored data in a linear fashion.
Trees- Stores data in a non linear fashion with one root node and sub nodes.

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

The scheme of organizing related information is known as ‘data structure’. The types of data structure are:
Lists: A group of similar items with connectivity to the previous or/and next data items.
Arrays: A set of homogeneous values
Records: A set of fields, where each field consists of data belongs to one data type.
Trees: 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.
Tables: Data is persisted in the form of rows and columns. These are similar to records, where the result or manipulation of data is reflected for the whole table. 

Define a linear and non linear data structure.

Linear data fashion- 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.
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.

Define a linear and non linear data structure.

Linear data structure: 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: 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 

Define in brief an array. What are the types of array operations?

An array is an arrangement of data arranged in a systematic order. An array usually has rows and columns. Each element of an array is accessed using the row and column id.
Array operations:-
Initializing an array:- Specifies the array size. Example: Arr[10];
Assigning :- This operation assigns a value to an array. Example: arr[1]=5;
There are many other operators that can be used to assign.

Define in brief an array. What are the types of array operations?

An array is a set of homogeneous elements. Every element is referred by an index. 
 Arrays are used for storing the data until the application expires in the main memory of the computer system. So that, the elements can be accessed at any time. The operations are:
- Adding elements
- Sorting elements
- Searching elements
- Re-arranging the elements 
- Performing matrix operations
- Pre-fix and post-fix operations

What is a matrix? Explain its uses with an example

Matrix is a way to store data in an organized form in the form of rows and columns. Matrices are usually used in computer graphics to project 3-dimensional space onto a 2-dimensional screen. Matrices in the form of arrays are used to store data in an organized form.

What is a matrix? Explain its uses with an example

A matrix is a representation of certain rows and columns, to persist homogeneous data. It can also be called as double-dimensioned array.
Uses:
- To represent class hierarchy using Boolean square matrix
- For data encryption and decryption
- To represent traffic flow and plumbing in a network
- To implement graph theory of node representation 

Define an algorithm. What are the properties of an algorithm? What are the types of algorithms?

An algorithm is a series of steps or methodology to solve a problem.
Properties of an algorithm:-
It is written in simple English. 
Each step of an algorithm is unique and should be self explanatory. 
An algorithm must have at least one input. 
An algorithm must have at least one output. 
An algorithm has finite number of steps.
Types:-
Types of algorithms are categorized based on the context they are spoken about. Some commonly used: 
Brute force:- An extremity raw method that aims to finds variety of solutions and which ones the best. 
Reduction:- Tries and converts the given problem to a simpler and a better known problem whose complexity is not dominated by the resulting reduced algorithm's. Linear programmings, Graphs, random are the other types of algorithms.

Define an algorithm. What are the properties of an algorithm? What are the types of algorithms?

Algorithm: A step by step process to get the solution for a well defined problem.
 Properties of an algorithm:
- Should be written in simple English
- Should be unambiguous, precise and lucid
- Should provide the correct solutions 
- Should have an end point
- The output statements should follow input, process instructions
- The initial statements should be of input statements
- Should have finite number of steps
- Every statement should be definitive
Types of algorithms:
-- Simple recursive algorithms. Ex: Searching an element in a list
– Backtracking algorithms Ex: Depth-first recursive search in a tree
– Divide and conquer algorithms. Ex: Quick sort and merge sort
– Dynamic programming algorithms. Ex: Generation of Fibonacci series
– Greedy algorithms Ex: Counting currency 
– Branch and bound algorithms. Ex: Travelling salesman (visiting each city once and minimize the total distance travelled)
– Brute force algorithms. Ex: Finding the best path for a travelling salesman
– Randomized algorithms. Ex. Using a random number to choose a pivot in quick sort).

No comments:

Post a Comment