Algorithms Practice Test

0%

What is the definition of an algorithm?

Correct! Wrong!

Explanation
Algorithms are used to specify how calculations, data processing, automated reasoning, automated decision-making, and other tasks should be carried out. A heuristic, on the other hand, is a problem- solving methodology that use practical methods and/or varied estimates to develop solutions that may not be ideal but are adequate given the circumstances.

Isn't it true that algorithms are only used in computers?

Correct! Wrong!

Explanation
The majority of algorithms are designed to be used as computer programs. Algorithms can also be implemented in a biological neural network (for example, the human brain doing arithmetic or an insect searching for food), an electrical circuit, or a mechanical device.

What's the difference between pseudocode and a flowchart?

Correct! Wrong!

Explanation
The major distinction between a flowchart and pseudocode is that a flowchart depicts a step-by-step process for completing a task. Pseudocode, on the other hand, is a notation for program design that resembles a rudimentary programming language. A flowchart depicts a series of actions that lead to an understandable result.

Why is it necessary to use a flowchart?

Correct! Wrong!

Explanation
Any flowchart's objective is to aid in the visualization of required steps, which is especially significant in the project management process. Actions, roles responsible for executing those actions, and inputs and outputs for each step are all included in each flowchart.

The upper bound is defined by this algorithm analysis.

Correct! Wrong!

Explanation
The Big O notation is used to define an algorithm's upper bound; it only bounds a function from above. Take the case of Insertion Sort, for example. In the best situation, it takes linear time, while in the worst case, it takes quadratic time.

What are the three different types of algorithm constructs?

Correct! Wrong!

Explanation
There are THREE basic programming constructs.
- Sequence logic is used for performing instructions one after another in sequence.
- Selection logic, also known as decision logic, is used for making decisions.
- Iteration logic is also known as Loop. Iteration logic is used when one or more instructions may be executed several times depending on some condition.

This algorithm analysis assesses a program's best case scenario.

Correct! Wrong!

Explanation
The lower bound of an algorithm's execution time is expressed using the Big-Omega notation (). 2 It determines the worst-case time complexity, i.e., 3 the shortest time an algorithm can take to complete.

Uses of quick sort

Correct! Wrong!

Explanation
Quick sort is an extremely efficient sorting technique that divides a large data array into smaller ones.

Except for one, these are sorting algorithms:

Correct! Wrong!

Explanation
A linear process or development is one in which anything changes or advances in a straight line from one stage to the next, with a beginning and a finish.

Except for one, these are algorithm paradigms:

Correct! Wrong!

Explanation
The correct answer
Searching

Which of the following algorithms has a time complexity of n log (n)?

Correct! Wrong!

Explanation
Insertion sort is a simple sorting algorithm in which each item in the final sorted array (or list) is added one at a time. On huge lists, it is substantially less efficient than more complex algorithms like quicksort, heapsort, or merge sort.

The data for an array utilized in a program will be saved in.

Correct! Wrong!

Explanation
Dope vectors are most typically used to represent arrays, which are used to hold numerous instances of the same datatype in a same block of memory.

An algorithm's order determines whether a given boolean function of 'n' variables returns a '1' is

Correct! Wrong!

Explanation
The algorithm exponential search is used to search sorted, unbounded/infinite arrays. The goal is to find a range in which the target value can be found and then do a binary search within that range.

The term "divide-and-conquer" applies to

Correct! Wrong!

Explanation
Divide and conquer is an algorithm design approach used in computer science. A divide-and-conquer algorithm iteratively divides a problem into two or more sub-problems of the same or related type until they are simple enough to be solved directly. The sub-problems' solutions are then integrated to produce a solution to the original problem.

Which algorithm solves the shortest path problem for all pairs?

Correct! Wrong!

Explanation
Dijkstra's algorithm is a method for calculating the shortest distance between two points.

The Big-O notation is used to represent

Correct! Wrong!

Explanation
The correct answer
Reduction of functions

The Dijkstra Algorithm has the following applications:

Correct! Wrong!

Explanation
The correct answer
All of the above

What is the Dijkstra Algorithm's running time?

Correct! Wrong!

Explanation
Because it pushes each reachable vertex onto the queue and considers each outgoing edge from it once, the running time of that method is O(V+E), where V is the number of vertices and E is the number of edges.

Which of the following is not a property of an algorithm?

Correct! Wrong!

Explanation
The correct answer
Infiniteness

The following algorithms can be used in a snake game.

Correct! Wrong!

Explanation
The correct answer
All of the above

Consider two L1 and L2 sorted lists. In the worst-case scenario, the number of comparisons required by my merge sort algorithm will be

Correct! Wrong!

Explanation
The correct answer
L1+L2-1

We'll need the following items to organize a binary tree in ascending order:

Correct! Wrong!

Explanation:
Because it returns values from the underlying set in order, according to the comparator that set up the binary search tree, in-order traversal is often employed on binary search trees. When deleting or freeing nodes and values in post-order traversal, a complete binary tree can be deleted or freed. As a result, the node is liberated once its children are freed.

The problem called can be solved with polynomial worst-case complexity.

Correct! Wrong!

Explanation
The class P includes all problems that can be solved in polynomial time, that is, in the worst-case, in time O (nk), where k is constant. Tractable issues are those that are easily solved, whereas intractable or superpolynomial problems are those that are difficult to solve.

The best way for arranging library books is

Correct! Wrong!

Explanation
Heap sort is a sorting algorithm that uses the Binary Heap data structure to compare items. It's comparable to selection sorting, in which we find the smallest element first and place it at the top.

Which method do we use to choose a hash function at random to avoid incorrect hashing behavior caused by a specific set of keys?

Correct! Wrong!

Explanation:
Universal Hashing chooses a hash function at random, regardless of the keys to be saved. In universal hashing, we choose a hash function at random from a properly designed family of functions at the start of the execution.