0% found this document useful (0 votes)
2 views3 pages

Algorithm QA

The document provides a comprehensive overview of algorithms and data structures, defining key concepts such as algorithms, efficiency factors, sorting techniques, and specific algorithms like Horspool's for pattern matching. It outlines criteria that algorithms must meet, discusses the brute force method, and explains concepts like transitive closure and minimum spanning trees. Additionally, it covers problem-solving techniques such as backtracking and the sum of subset problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Algorithm QA

The document provides a comprehensive overview of algorithms and data structures, defining key concepts such as algorithms, efficiency factors, sorting techniques, and specific algorithms like Horspool's for pattern matching. It outlines criteria that algorithms must meet, discusses the brute force method, and explains concepts like transitive closure and minimum spanning trees. Additionally, it covers problem-solving techniques such as backtracking and the sum of subset problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Algorithm & Data Structures - Q&A

1. Define Algorithm. List out the criteria's that all algorithms must satisfy.

An algorithm is a finite sequence of well-defined instructions used to solve a problem or perform a computation.

Criteria:

- Input: Zero or more inputs provided externally.

- Output: At least one output/result.

- Finiteness: Must terminate after a finite number of steps.

- Definiteness: Each step must be clearly and unambiguously defined.

- Effectiveness: All operations must be basic enough to be performed exactly and in a finite time.

2. On what factors efficiency of an algorithm depends?

Efficiency depends on:

- Time Complexity

- Space Complexity

- Input Size

- Type of Input

- Constants and Lower Order Terms

3. Arrange the following functions in ascending order: n, 2^n, n!, n^3, nlogn, logn, n^2

Ascending order: logn < n < nlogn < n^2 < n^3 < 2^n < n!

4. Define Brute force method. List out the problems that can be solved using this method.

Brute Force is a straightforward method of solving a problem by trying all possible solutions.
Algorithm & Data Structures - Q&A

Problems:

- String Matching

- TSP

- Sorting

- Searching

- Matrix Multiplication

5. Define sorting. List any two sorting techniques.

Sorting is arranging data in a specified order (ascending or descending).

Two techniques:

1. Bubble Sort

2. Quick Sort

6. Mention the steps involved in merge sort.

Steps:

1. Divide the array into halves

2. Recursively sort both halves

3. Merge the sorted halves

7. Define i) Transitive Closure ii) Adjacency Matrix

i) Transitive Closure: A graph showing reachability of vertices.

ii) Adjacency Matrix: A 2D array representing graph edges.


Algorithm & Data Structures - Q&A

8. State Horspool's algorithm for pattern matching.

Uses a shift table to skip unnecessary comparisons:

- Preprocess pattern

- Compare from right

- Shift using table on mismatch

9. Define i) Feasible Solution ii) Optimal Solution

i) Feasible Solution: Satisfies all constraints.

ii) Optimal Solution: Best among all feasible ones.

10. Define Minimum Spanning Tree.

A subset of edges that connects all vertices with minimum total weight and no cycles.

11. What is Backtracking?

A technique to solve problems by exploring options and backtracking upon failure, e.g., N-Queens.

12. What is sum of sub-set problem?

To find if a subset exists whose sum equals a given value. Solved using backtracking or DP.

You might also like