Ticker

6/recent/ticker-posts

Data structure subjective question for competitive exam(2)

Q1.Algorithm and characteristic of algorithm.

Definition: - An algorithm is a Step By Step process to solve a problem, where each step indicates an intermediate task. Algorithm contains finite number of steps that leads to the solution of the problem. Properties /Characteristics of an Algorithm:- Algorithm has the following basic properties  Input-Output:- Algorithm takes ‘0’ or more input and produces the required output. This is the basic characteristic of an algorithm.  Finiteness:- An algorithm must terminate in countable number of steps.  Definiteness: Each step of an algorithm must be stated clearly and unambiguously.  Effectiveness: Each and every step in an algorithm can be converted in to programming language statement.  Generality: Algorithm is generalized one. It works on all set of inputs and provides the required output. In other words it is not restricted to a single input value.



Q2.Explain operation on data struucture.

Operations on the Data Structures: Following operations can be performed on the data structures: 1. Traversing 2. Searching 3. Inserting 4. Deleting 5. Sorting 6. Merging 1. Traversing- It is used to access each data item exactly once so that it can be processed. 2. Searching- It is used to find out the location of the data item if it exists in the given collection of data items. 3. Inserting- It is used to add a new data item in the given collection of data items. 4. Deleting- It is used to delete an existing data item from the given collection of data items. 5. Sorting- It is used to arrange the data items in some order i.e. in ascending or descending order in case of numerical data and in dictionary order in case of alphanumeric data. 6. Merging- It is used to combine the data items of two sorted files into single file in the sorted form.



Q3.Diff b/w stack and queue.

Stack 1.A stack is a linear list of elements in which the element may be inserted or deleted at one end. 2. In stacks, elements which are inserted last is the first element to be deleted. 3.Stacks are called LIFO (Last In First Out)list 4.In stack elements are removed in reverse order in which thy are inserted. 5.suppose the elements a,b,c,d,e are inserted in the stack, the deletion of elements will be e,d,c,b,a. 6.In stack there is only one pointer to insert and delete called “Top”. 7.Initially top=-1 indicates a stack is empty. 8.Stack is full represented by the condition TOP=MAX-1(if array index starts from ‘0’). 9.To push an element into a stack, Top is incremented by one 10.To POP an element from stack,top is decremented by one. Queue 1.A Queue is a linerar list of elements in which the elements are added at one end and deletes the elements at another end. 2. . In Queue the element which is inserted first is the element deleted first. 3. Queues are called FIFO (First In First Out)list. 4. In Queue elements are removed in the same order in which thy are inserted. 5. Suppose the elements a,b,c,d,e are inserted in the Queue, the deletion of elements will be in the same order in which thy are inserted. 6. In Queue there are two pointers one for insertion called “Rear” and another for deletion called “Front”. 7. Initially Rear=Front=-1 indicates a Queue is empty. 8.Queue is full represented by the condition Rear=Max-1. 9.To insert an element into Queue, Rear is incremented by one. 10.To delete an element from Queue, Front is incremented by one.


Q4.Diff b/w array and linklist.

1. Arrays are used in the predictable storage requirement ie; exert amount of data storage required by the program can be determined. 2. In arrays the operations such as insertion and deletion are done in an inefficient manner. 3. The insertion and deletion are done by moving the elements either up or down. 4. Successive elements occupy adjacent space on memory. 5. In arrays each location contain DATA only 6. The linear relation ship between the data elements of an array is reflected by the physical relation ship of data in the memory. 7. In array declaration a block of memory space is required. 8.There is no need of storage of pointer or lines Linklist 1. Linked List are used in the unpredictable storage requirement ie; exert amount of data storage required by the program can’t be determined. 2. In Linked List the operations such as insertion and deletion are done more efficient manner ie; only by changing the pointer. 3. The insertion and deletion are done by only changing the pointers. 4. Successive elements need not occupy adjacent space. 5. In linked list each location contains data and pointer to denote whether the next element present in the memory. 6. The linear relation ship between the data elements of a Linked List is reflected by the Linked field of the node. 7. In Linked list there is no need of such thing. 8. In Linked list a pointer is stored along into the element.


Q5.explain type of sorting technique.

Types of Sorting Techniques: Sorting techniques are categorized into 2 types. They are Internal Sorting and External Sorting. Internal Sorting: Internal sorting method is used when small amount of data has to be sorted. In this method , the data to be sorted is stored in the main memory (RAM).Internal sorting method can access records randomly. EX: Bubble Sort, Insertion Sort, Selection Sort, Shell sort, Quick Sort, Radix Sort, Heap Sort etc. External Sorting: Extern al sorting method is used when large amount of data has to be sorted. In this method, the data to be sorted is stored in the main memory as well as in the secondary memory such as disk. External sorting methods an access records only in a sequential order. Ex: Merge Sort, Multi way Mage Sort.



Post a Comment

0 Comments