Algorithm interview questions

6. What is Bubble sort ?
Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.The algorithm, which is a comparison sort, is named for the way smaller or larger elements “bubble” to the top of the list.Bubble sort is an algorithm that compares the adjacent elements and swaps their positions if they are not in the intended order.

7. What is Divide and Conquer algorithms ?
In computer science, divide and conquer is an algorithm design paradigm based on multi-branched recursion. A divide-and-conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.
Divide: Algorithm divides the original problem into a set of subproblems.
Conquer: Algorithm solves every subproblem individually.
Combine: Algorithm puts together the solutions of the subproblems to get the solution to the whole problem.

8. What is Breadth-first search algorithm ?
Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a ‘search key’ ), and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level.

9. What is Dijkstra’s Shortest Path Algorithm ?
Dijkstra’s Shortest Path Algorithm. One algorithm for finding the shortest path from a starting node to a target node in a weighted graph is Dijkstra’s algorithm. The algorithm creates a tree of shortest paths from the starting vertex, the source, to all other points in the graph.

10. Give examples of divide and conquer algorithm ?
The following are some standard algorithms that follows Divide and Conquer algorithm.
Binary Search is a searching algorithm.
Quicksort is a sorting algorithm.
Merge Sort is also a sorting algorithm.

Author: user

Leave a Reply