*Short Answer types Question on Data Structure*

*1. How do you create an empty linked list?*

*This variable is used to point to the first element of the list Since the list will be empty in the beginning, the variable head is assigned a sentinel value to indicate that the list is empty.*

*void create_empty_list(node **head)*

*{*

**head=NULL;*

*}*

*2. Name some operations on Linked Lists.*

*The main operations that are performed on a linked list are the following:*

*a. Traversing*

*b. Searching*

*c. Inserting*

*d. Deleting*

*3. Define AVL trees.*

*An AVL tree is a binary search tree which has the following properties:*

*a. The sub-trees of every node differ in height by at most one.*

*b. Every sub-tree is an AVL tree.*

*4. Explain Djiksatras algorithm.*

*Djikstra's algorithm (named after its discover, E.W. Dijkstra) solves the problem of finding the shortest path from a point in a graph (the source) to a destination. It turns out that one can find the shortest paths from a given source to all points in a graph in the same time, hence this problem is sometimes called the single-source shortest paths problem.*

*5. Write Selection Sort Algorithm.*

*Selection_sort(a,n):*

*Here a is the linear array with n elements. This algorithm sorts elements into ascending order. It uses a temporary variable temp to facilitate the exchange of two values and variable i is used as a loop control variable*

*Begin*

*for i=1 to (n-1) by 1 do*

*call Smallest_element(a,n,i,loc)*

*set temp=a[i-1]*

*set a[i-1]=a[loc]*

*set a[loc]=temp*

*end for*

*end*

*6. Explain circularly linked lists.*

*By ensuring that the tail of the list is always pointing to the head, we can build a circularly linked list. If the external pointer (the one in struct t_node in our implementation), points to the current "tail" of the list, then the "head" is found trivially via tail->next, permitting us to have either LIFO or FIFO lists with only one external pointer. In modern processors, the few bytes of memory saved in this way would probably not be regarded as significant. A circularly linked list would more likely be used in an application which required "round-robin" scheduling or processing.*

*7. What is a binary tree?*

*The simplest form of tree is a binary tree. A binary tree consists of*

*a. A node called the root node*

*b. Left and Right sub-trees.*

*Both the sub-trees are themselves binary trees.*

*8. What is a spanning Tree?*

*Ans: A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.*

*9. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?*

*No, because in minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.*

*10. Write the syntax for multiplication of matrices?*

*for (=0; < val;++)*

*{*

*for (=0; < val;++)*

*{*

*for (=0; < val;++)*

*{*

*arr[var1][var2] += arr[var1][var3] * arr[var3][arr2];*

*}*

*}*

*}*

*Thanks*

*Mukesh Rajput*
## No comments:

## Post a Comment

Thanks

Mukesh Rajput