0% found this document useful (0 votes)
4 views

Algorithm_Questions_and_Answers_Extended

Hii

Uploaded by

anishk33798
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Algorithm_Questions_and_Answers_Extended

Hii

Uploaded by

anishk33798
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Algorithm Questions and Answers

1. What is an Algorithm?

An algorithm is a finite set of instructions or logic, written in order, to accomplish a certain predefined

task.

2. What are the characteristics of an Algorithm?

An algorithm must be clear, finite, effective, and should produce the desired output.

3. Define Time Complexity.

Time complexity is the computational complexity that describes the amount of time an algorithm

takes to run as a function of the length of the input.

4. Define Space Complexity.

Space complexity is the amount of memory space required to solve a problem as a function of the

input size.

5. What is Big-O Notation?

Big-O notation is a mathematical representation used to describe the upper bound of an algorithm's

runtime or space requirement.

6. What is an Example of a Divide and Conquer Algorithm?

Merge Sort is an example of a divide and conquer algorithm.

7. Define Recursion in Algorithms.

Recursion is a method where the solution to a problem depends on solutions to smaller instances of

the same problem.

8. What is a Greedy Algorithm?

A greedy algorithm builds up a solution piece by piece, choosing the next piece that offers the most
immediate benefit.

9. What is Dynamic Programming?

Dynamic programming is a method for solving complex problems by breaking them down into

simpler subproblems and solving them just once, storing their solutions.

10. What is Backtracking?

Backtracking is an algorithmic technique for solving problems recursively by trying to build a solution

incrementally.

11. Define a Heuristic Algorithm.

A heuristic algorithm is one that finds a good enough solution for a problem quickly when classic

methods are too slow or fail to find any exact solution.

12. What is Breadth-First Search (BFS)?

BFS is a traversal algorithm for graphs that starts at a source node and explores all neighboring

nodes at the current depth before moving to nodes at the next depth level.

13. What is Depth-First Search (DFS)?

DFS is a traversal algorithm for graphs that explores as far as possible along a branch before

backtracking.

14. What is a Sorting Algorithm?

A sorting algorithm is used to rearrange a given array or list elements according to a comparison

operator on the elements.

15. What is Quick Sort?

Quick Sort is a sorting algorithm that uses the divide and conquer approach to sort elements by

partitioning the array into two subarrays.

16. Explain Binary Search.


Binary Search is a searching algorithm that finds the position of a target value within a sorted array

by repeatedly dividing the search interval in half.

17. What is Linear Search?

Linear Search is a simple searching algorithm that checks each element of the list sequentially until

the desired element is found or the list ends.

18. Define Hashing.

Hashing is the process of converting an input into a fixed-size string of characters, which is usually a

hash code.

19. What is a Hash Table?

A hash table is a data structure that maps keys to values for highly efficient lookup.

20. What is an Algorithm's Input and Output?

The input is the data provided to the algorithm, and the output is the result obtained after executing

the algorithm on the input.

21. Explain the Pseudocode.

Pseudocode is a high-level description of an algorithm, intended for humans rather than machines.

22. What is the Difference Between an Algorithm and a Program?

An algorithm is a step-by-step logical procedure, while a program is the implementation of an

algorithm in a programming language.

23. Define NP-Completeness.

NP-completeness refers to a class of problems for which no efficient solving algorithm has been

found but can be verified quickly.

24. What is the Traveling Salesman Problem?

The traveling salesman problem is a classic optimization problem that asks for the shortest possible
route that visits each city and returns to the origin city.

25. What is the Knapsack Problem?

The knapsack problem is a problem in combinatorial optimization where the goal is to maximize the

total value of items in a knapsack without exceeding its capacity.

26. Define the Fibonacci Sequence.

The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding

ones, usually starting with 0 and 1.

27. What is the Tower of Hanoi?

The Tower of Hanoi is a mathematical puzzle where you move a set of disks from one rod to

another, following certain rules.

28. Explain Sorting Stability.

A sorting algorithm is stable if it preserves the relative order of records with equal keys.

29. 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.

30. What is Insertion Sort?

Insertion Sort is a simple sorting algorithm that builds the final sorted array one item at a time.

31. What is Selection Sort?

Selection Sort is a sorting algorithm that repeatedly selects the smallest element from the unsorted

part and moves it to the sorted part.

32. What is Merge Sort?

Merge Sort is a divide and conquer algorithm that splits the array into halves, sorts them, and then

merges them back together.


33. What is Radix Sort?

Radix Sort is a non-comparative sorting algorithm that sorts integers by processing individual digits.

34. What is a Priority Queue?

A priority queue is a data structure where each element has a priority and elements are served

based on their priority.

35. What is Graph Representation?

Graphs can be represented using adjacency lists, adjacency matrices, or incidence matrices.

36. What is a Spanning Tree?

A spanning tree is a subset of a graph that connects all the vertices together without forming any

cycles.

37. Explain Prim's Algorithm.

Prim's Algorithm is used to find the minimum spanning tree of a graph by selecting the smallest

weight edge at each step.

38. Explain Kruskal's Algorithm.

Kruskal's Algorithm finds the minimum spanning tree by sorting all edges and adding them one by

one to the tree.

39. What is Dijkstra's Algorithm?

Dijkstra's Algorithm finds the shortest path between a source node and all other nodes in a weighted

graph.

40. What is Floyd-Warshall Algorithm?

The Floyd-Warshall Algorithm is a graph algorithm for finding shortest paths in a weighted graph

with positive or negative edge weights.

You might also like