State the logic of bubble sort algorithm.

The bubble sort repeatedly compares adjacent elements of an array. The first and second elements are compared and swapped if out of order. Then the second and third elements are compared and swapped if out of order. This sorting process continues until the last two elements of the array are compared and swapped if out of order.

Why bubble sort is called so?

The bubble sort gets its name because as array elements are sorted they gradually “bubble” to their proper positions, like bubbles rising in a glass of soda.

What is meant by Sorting?

Sorting is ordering of data in an increasing or decreasing fashion according to some linear relationship among the data items.

Graph Data Structure Practice Questions

  1. Explain the various representation of graph with example in detail?
  2. Explain Breadth First Search algorithm with example?
  3. Explain Depth first and breadth first traversal?
  4. What is topological sort? Write an algorithm to perform topological sort?(8) (Nov 09)
  5. (i) write an algorithm to determine the biconnected components in the given graph. (10) (may
    (ii)determine the biconnected components in a graph. (6)
  6. Explain the various applications of Graphs.

Articulation Points (or Cut Vertices) in a Graph

A vertex in an undirected connected graph is an articulation point (or cut vertex) if removing it (and edges through it) disconnects the graph. Articulation points represent vulnerabilities in a connected network single points whose failure would split the network into 2 or more disconnected components. They are useful for designing reliable networks.

Define biconnected graph?

A graph is called biconnected if there is no single node whose removal causes the graph to break into two or more pieces. A node whose removal causes the graph to become disconnected is called a cut vertex.

Write BFS algorithm

  1. Initialize the first node’s dist number and place in queue
  2. Repeat until all nodes have been examined
  3. Remove current node to be examined from queue
  4. Find all unlabeled nodes adjacent to current node
  5. If this is an unvisited node label it and add it to the queue
  6. Finished.

What is topological sort?

It is an ordering of the vertices in a directed acyclic graph, such that: If there is a path from u to v, then v appears after u in the ordering.