Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve as soon as possible. Thank you. 1. ( 30 points) Write a computer program that finds the first 20 numbers of the Fibonacci

Please solve as soon as possible. Thank you. image text in transcribed
1. ( 30 points) Write a computer program that finds the first 20 numbers of the Fibonacci sequence and puts into a list. 2. (50 points) Write a computer program that defines the class "Set" (assume that the elements are integers). The class should contain methods to perform the operations listed below. Write a test program that tests your "Set" class. a) Different constructors to initialize the set (one is to set the elements from a one-dimension array) b) union: find the union of the set with a given set. OUTPUT: a Set object. c) intersection: find the intersection of the set with a given set. OUTPUT: a Set object. d) difference: find the difference of the set and the given set (Set - given Set). OUTPUT: a Set object. e) Cartesian product: find the Cartesian product (Set X given set). OUTPUT: prints out the product. f) Check whether the set is a subset of another set. OUTPUT: True or False. 8) Find the powerset of the set. OUTPUT: prints out the powerset. h) isEmpty method that returns true if the set is empty (no elements). i) isElement method that takes an element and check if it is an element of the set. j) isEqual method that check if the set is equal to a given set. k) getCardinality method that returns the cardinality of the set. I) addElement method that adds element to the set. Make sure that you don't add an existing element. You will use isElement check before you try to add it. m) removeElement method to remove an element from the set. n) Clear method to remove all elements of the set. o) toArray that converts the object of the Set class to a one-dimensional array. p) print method to print the elements of the set. In your test program, declare two sets objects and use the constructor to initialize them by sending a onedimension array contains the elements of the set. 3. ( 10 points) Prove that 3n<>

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_2

Step: 3

blur-text-image_3

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions