

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
Material Type: Notes; Class: Design/Analysis of Algorithms; Subject: Computer Science; University: University of the Pacific; Term: Fall 2007;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!
Brute force solution to Push Button Lock: A Test is one possible assignment of buttons Æ combinations: Recursively build all possible button Æ combination assignments (including invalid ones). Check if a button Æ combination assignment is valid: struct Test { int x[11]; int n; Test(int _n) { n = _n; } Test(const Test& o) { n=o.n; for (int i=0; i<o.n; i++) x[i]=o.x[i]; } }; void make_tests(int n, int max, vector
Solve the problem for a specific number of buttons: Official judge’s solution to Push Button Lock (not brute force?): int solve(int num_buttons) { // make vector containing all possible assignments vector