Algorithm Definition
What is an algorithm?
- A data structure used for storing information.
- A type of computer hardware.
- A finite sequence of well-defined instructions used to solve a class of problems or conduct a computation in mathematics and computer science.
- A programming language.
- A method of avoiding compiler errors.
Advantages of Algorithms
Which of the following is a benefit of using algorithms?
- Algorithms increase the cost of design.
- Algorithms reduce the effectiveness of existing methods.
- Algorithms boost the effectiveness of an existing method.
- Algorithms prevent a reasonable comprehension of the program's flow.
- Algorithms evaluate how poorly the approaches work in various scenarios.
Comparing Algorithms
How can we compare between two algorithms written for the same problem?
- By the amount of comments they contain.
- By the language they are written in.
- By the complexity of an algorithm, a technique that is used to categorise how efficient it is in comparison to other algorithms.
- By the number of lines of code.
- By their aesthetic appeal.
DFS Algorithm
What does DFS stand for in the context of algorithms?
- Data Flow System.
- Depth First Search.
- Directed File Search.
- Distributed Function Service.
- Definitive Formatting Structure.
BFS Algorithm
What data structure is typically used to implement BFS?
- Stack.
- Queue.
- Tree.
- Graph.
- Linked List.
String Reversal
Given the string hello, what would be the output of a string reversal algorithm?
- oellh
- Hello
- olleh
- helol
- lleho
Dynamic Programming
What is the primary purpose of Dynamic Programming?
- To reduce memory usage.
- To increase code readability.
- Dynamic Programming is primarily a recursion optimization.
- To eliminate all recursion.
- To improve network performance.
Binary Tree Leaf Nodes
What is the return value of an algorithm to count leaf nodes in a binary tree when given a null node?
- Null
- Error
- 0
- 1
- -1
Sorted Linked List Insertion
What is the first step in an algorithm for adding a node to a linked list sorted in ascending order?
- Find the largest node.
- Check if the linked list has no value (or is empty).
- Sort the linked list.
- Reverse the linked list.
- Remove duplicate nodes.
Binary Search
What is a prerequisite for applying binary search on a list of elements?
- The list must be empty.
- The list must be unsorted.
- The list must be sorted.
- The list must contain only positive numbers.
- The list must be a linked list.
Linear Search
What is the time complexity of the Linear Search Algorithm?
- O(log n)
- O(1)
- O(n)
- O(n log n)
- O(n^2)
Searching Algorithms
Which of the following is an example of an Interval Search Algorithm?
- Linear Search.
- Binary Search.
- Depth-First Search.
- Breadth-First Search.
- Sequential search
Greedy Algorithms
What is the defining characteristic of a greedy algorithm?
- It always finds the optimal solution.
- It aims to choose the best optimal decision at each sub-step, eventually leading to a globally optimal solution.
- It guarantees the fastest execution time.
- It requires a large amount of memory.
- It always avoids recursion.
Divide and Conquer Paradigm
What are the main steps of the Divide and Conquer algorithmic paradigm?
- Sort, Search, Print
- Divide, Multiply, Conquer
- Divide, Conquer, Combine
- Input, Process, Output
- Create, Read, Update, Delete
Number Swapping
Which bitwise operator is commonly used to swap two numbers without a temporary variable in Java, C, or C++?
- AND (u0026)
- OR (|)
- XOR (^)
- NOT (!)
- Shift (u003Eu003E or u003Cu003C)
Asymptotic Notations
Which asymptotic notation defines an upper bound for an algorithm?
- Big Theta Notation.
- Big Omega Notation.
- Big O Notation.
- Small o Notation.
- Small omega notation
Algorithm Case Scenarios
What does the average-case complexity of an algorithm represent?
- The performance with the best possible input.
- The amount of some computational resource (usually time) used by the process, averaged over all possible inputs, according to computational complexity theory.
- The performance with the worst possible input.
- The time required to initialize the algorithm.
- The memory usage of the algorithm.
Encryption Algorithms
What is the process of transforming plaintext into ciphertext called?
- Hashing
- Encoding
- Encryption
- Compression
- Abstraction
Selection Sort Space Complexity
What is the space complexity of the selection sort algorithm?
- O(log n)
- O(n)
- O(n log n)
- O(1)
- O(n^2)
Insertion Sort Space Complexity
What is the space complexity of the insertion sort algorithm?
- O(log n)
- O(n)
- O(n log n)
- O(n^2)
- O(1)