






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Assignment 01 - Discrete Maths in BTEC Higher National Diploma in Computing
Typology: Essays (university)
1 / 11
This page cannot be seen from the preview
Don't miss anything!
Summative Feedback:
Internal verification:
Figure 1: Set and multiset example ........................................................................................ 6 Figure 2: Function example ................................................................................................. 10
1. Let A and B be two non-empty finite sets. If cardinalities of the sets A , B , and A ∩ B are 72, 28, and 13 respectively, find the cardinality of the set A ∪ B n ( A ∪ B ) = n( A ) + n( B ) – n( A ∩ B ) = 72 + 28 - 13 = 87 2. Let A = {n ∈ N: 20 ≤ n < 50} and B = {n ∈ N: 10 < n ≤ 30}. Suppose C is a set such that C ⊆ A and C ⊆ B****. What is the largest possible cardinality of C****? Since: C ⊆ A and C ⊆ B <=> C ⊆ A ∩ B => C = {n ∈ N | 20 ≤ n ≤ 30} <=> C ⊆ {20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30} = 11 So, the largest possible cardinality of C is 11. 3. C onsider the sets A and B , where A = {3, | B |} and B = {1, | A |, | B |}. What are the sets? If | A| = 1 then B = {1, 1, | B |} and A = {3, | B | = 3} B = {1, 1, | B |} <=> B = {1, | B |} <=> B = {1, 3} => | B | = 2 => Wrong! If | A | = 2 then B = {1, 2, | B| } and A = {3, | B| ≠ 3 } and |B| < 3
import import java.util.ArrayListjava.util.HashSet; ; import import java.util.java.util. ListSet ;; public class public static void Main { main(String[] args){ // Using Set Set
And here we have the result, as you can see the names John and Gary can be duplicated on the multiset.
Figure 1 : Set and multiset example
1. Determine whether the following functions are invertible or not. If it is invertible, then find the rule of the inverse f-1 (x)
i. f (x) = x^2 If x = 2, then f(x) = 4 If x = - 2 then f(x) = 4 From two statements above => The function f(x) = x^2 is not one-to-one. So in conclusion, the function is not invertible
ii. f(x) = (^) 𝑥^1
Let y = (^1) 𝑥 with y ≠ 0 <=> x = (^1) 𝑦 <=> x × y = (^1) 𝑦 × y <=> x × y = 1 <=> y = (^1) 𝑥 So the function is invertible and f-1(x) = (^) 𝑥^1
2. Function f(x) = 𝟓 𝟗 (x-32) converts Fahrenheit temperatures into Celsius. What is the function for opposite conversion? Let y = 59 (x-32) <=> 9y = 5x – 160 <=> 9y + 160 = 5x <=> x = 95 y + 32 So the opposite function, which converts Celsius to Fahrenheit is 95 x + 32 where x is the temperature in Celsius. 3. Present the application of function in software engineering? Give a specific programming example The main purpose of any function is to take an input and return the correct output. So by using functions, software developers can make their programs perform tasks from simple to extremely complex involving complicated logic ones. Here is an example of using a function to convert Mile to Kilometer in Java public class final static double Main { MI_TO_KM_CONSTANT = 1.6093; public static void main(String[] args) throws InterruptedException { System System..outout..printlnprintln(("1 mile to km: ""10 miles to km: " + convertMileToKm + convertMileToKm ( 1 ));( 10 )); System System..outout..printlnprintln(("25 miles to km: ""178 mile to km: " ++ convertMileToKmconvertMileToKm (( 25178 ));)); } public static double return mile * MI_TO_KM_CONSTANT convertMileToKm;(double mile){ }^ } And here are the result:
Figure 2 : Function example