Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

years ago. d Only using studies which feature empirical data.

Answered: 1 week ago