0% found this document useful (0 votes)
12 views1 page

Advanced Algorithms Assignment CS617

The document contains instructions for an assignment to write algorithms for 10 exercises: finding the largest number in a list, finding the m smallest numbers in a list, printing all subsets of 3 elements from a set, finding the greatest common divisor of two integers, finding the smallest and largest numbers in a list, printing the average of positive numbers in an array, testing if two arrays contain a common element, printing characters in alphabetical order, finding the smallest multiple of 3 integers, and determining if a number is perfect.

Uploaded by

Salman Ahmad
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Advanced Algorithms Assignment CS617

The document contains instructions for an assignment to write algorithms for 10 exercises: finding the largest number in a list, finding the m smallest numbers in a list, printing all subsets of 3 elements from a set, finding the greatest common divisor of two integers, finding the smallest and largest numbers in a list, printing the average of positive numbers in an array, testing if two arrays contain a common element, printing characters in alphabetical order, finding the smallest multiple of 3 integers, and determining if a number is perfect.

Uploaded by

Salman Ahmad
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Abasyn University Peshawar

Department of Computing
Course: CS617-Advanced Design & Analysis of Algorithm Teacher: Rashid Kamal
Assignment No. 1

Write algorithms for each of the exercises below.

1. Write an algorithm that finds the largest number in a list of n numbers.


2. Write an algorithm that finds the m smallest numbers in a list of n numbers.
3. Write an algorithm that prints out all the subsets of three elements of a set of n elements.
The elements of this set are stored in a list that is the input to the algorithm.
4. Write an algorithm that finds the greatest common divisor of two integers.
5. Write an algorithm that finds both the smallest and largest numbers in a list of n numbers.
6. Write an algorithm that takes an array of positive integers (it stops reading when it sees a
negative number), and the size of the array, and prints the average (type float) of the
values.
7. Given 2 arrays A and B, each of size n. Design an algorithm to test whether there is at
least one common element between the 2 arrays.
8. Read in any three characters (a-z) and print them in alphabetical order.
9. Write an algorithm that takes three integers and returns the smallest integer that is a
multiple of all three integers.
10. A perfect number is a positive integer greater than 1 that equals the sum of its divisors,
including 1 but not itself. For example, 6 is a perfect number because its divisors are 1, 2,
and 3 and 1 + 2 + 3 = 6. Write an algorithm that determines for a given integer whether it
is perfect or not.

You might also like