Question: Quiz #1 1-What is an algorithm, define its purpose (2) 2-What is wrong with this code which is checking to see if the number 5

Quiz #1

1-What is an algorithm, define its purpose (2)

2-What is wrong with this code which is checking to see if the number 5 is present in a given number - Explain (2)

Public static NumCheck (int num)

{

int last = num%10;

if (last == 5)

return true;

else

return NumCheck(num/10);

}

3-Public static void IsFibonacci (int number) {

..

}

Public static void IsFibonacci (String text) {

..

}

Is anything wrong with declaring the above 2 methods to be part of the same class? (1)

4-Explain in a few steps the backtracking algorithm ( 3)

5-What is the unique feature of a set and what are the 2 ways of declaring data structures that represent a set. (2)

6-Say what is the best data structure for the following problem (2)

a-To implement a student list in college

b-To implement a payroll at a company

7-Define below (2)

a-Best Case Algorithm

b-Worst Case Algorithm

8-Look at code below say which big O notation does the code below depict (1)

bool ContainsDuplicates(IList elements)

{

for (var outer = 0; outer < elements.Count; outer++)

{

for (var inner = 0; inner < elements.Count; inner++)

{

// Don't compare with self

if (outer == inner)

continue;

if (elements[outer] == elements[inner])

return true;

}

}

return false;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!