Q1: What is an algorithm and what are its characteristics? Are algorithms language specific?
Q2: What is pseudocode?
Hint: Refer to Week 1 lecture slides from pages 4 to 7.
Describe the standard algorithm for finding the decimal representation of a positive binary number (e.g., 1011 = 11).
a) in English
b) in the pseudocode defined in Lecture 1
ALGORITHM BinaryToDecimal(m)
// Given positive binary numberwith digits ( )
// Returns decimal representation of
...
return ...
Try to improve the following algorithm for finding the distance between the two closest elements in an array of numbers.
ALGORITHM ClosestDistance(
)
// Input: Arrayof numbers
// Output: Minimum distance between two of its elements
forto do
forto do
ifand
return
Implement the find closest distance algorithm in C#, and test it like:
int[] numbers = { 4, 10, 12, 3, 6, 9, 7, 15 };
int result = MinimumDistance(numbers);
Console.WriteLine($"Minimum distance: {result}");
// Expected output: 1 (the closest numbers are 6 and 7)
Implement a sorted list in C# with the following methods:
Insert(int value) to add a new element to the list at the correct positionDelete(int value) to remove an element from the listSearch(int value) to find an element in the listIsEmpty() and IsFull() to check if the list is empty or fullThere should also be two properties:
Count to return the number of elements in the listCapacity to return the maximum number of elements the list can hold