FE-Jan19.pdf-Page 1 of 4 Computer Scienc...
FE-Jan19.pdf-Page 1 of 4 Computer Science
Showing 16 out of 16
FE-Jan19.pdf-Page 1 of 4 Computer Science
FE-Jan19.pdf-Page 1 of 4 Computer Science
FE-Jan19.pdf-Page 1 of 4 Computer S...
FE-Jan19.pdf-Page 1 of 4 Computer Science
Page 16
Spring 2019
Algorithms and Analysis Tools Exam, Part B
3) (
10 pts) DSN (Bitwise Operators)
In this problem we will consider buying a collection of 20 figurines, labeled 0 through 19, inclusive. The
figurines come in packages. Each package has some non-empty subset of figurines. We can represent
the contents of a single package using an integer in between 1 and 2
1, inclusive, where the bits that
are on represent which figurines are in the package. For example, the integer 22 = 2
+ 2
+ 2
, would
represent a package with figurines 1, 2 and 4. Each month, one package comes out. You greedily buy
every package until you have all 20 figurines. Write a function that takes in an array of integers,
, and its length,
, where
stores an integer representing the contents of the package
on sale during month i, and returns the number of months you will have to buy packages to complete the
set. It is guaranteed that each figurine belongs to at least one of the packages and that each value in the
array packages is in between 1 and 2
-1, inclusive.
For full credit, you must use bitwise operators.
int monthsTillComplete(int packages[], int n) {

Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
University of Pune
Great resource for chem class. Had all the past labs and assignments
Leland P.
Santa Clara University
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades

Students also viewed documents