×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

by: Aliyah Boyer

5

0

6

# Program Cis Majors 2 CIS 3023

Aliyah Boyer
UF
GPA 3.58

Staff

These notes were just uploaded, and will be ready to view shortly.

Either way, we'll remind you when they're ready :)

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

COURSE
PROF.
Staff
TYPE
Class Notes
PAGES
6
WORDS
KARMA
25 ?

## Popular in Comm Sciences and Disorders

This 6 page Class Notes was uploaded by Aliyah Boyer on Friday September 18, 2015. The Class Notes belongs to CIS 3023 at University of Florida taught by Staff in Fall. Since its upload, it has received 5 views. For similar materials see /class/207037/cis-3023-university-of-florida in Comm Sciences and Disorders at University of Florida.

×

## Reviews for Program Cis Majors 2

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/18/15
Problem 1 De ne assertion terms pre conditions post conditions and invariants giving examples of the difference between prepost conditions and invariants Solution Precondition a condition that should be true for a method to execute correctly Example int ndMinint inputArray return inputArray 0 For this method the precondition needs to be de ned as inputArray1ength gt1 and inputArray is sorted We can also de ne it mathematically as inputArraylength gt 1 AND V i st 0 lt i lt inputArray1ength inputArrayi lt inputArray i1 OR inputArraylength 1 Postcondition a condition that will be true after a method terminates Example void s0rtint inputArray The postcondition will be inputArray is sorted Similar to the precondition we can also de ne it mathematically Invariant class invariant 1 a condition that should always be true during the execution should be true for each object of the class Example Assume that we have a class Person and the class has an attribute of type int with name currentMoney We can de ne a class invariant the value of currentMoney should never be less than 0 In this class there may be different methods which may modify the value of this attribute However this invariant ensures that none of them assigns a value less than 0 Problem 3 List the problem solving techniques discussed in lecture and give an example problem where each would be useful Solution Write the problem in your own words Ex The problem can be given as a mathematical formula as Given int a st alength gt 0 nd i st Vj ai lt am We can easily rephrase this problem as Find the index of the minimum element in a given array a Try to reach the solution by solving a simpler problem Ex In order to nd the 3rd minimum number in an array we can start with creating a solution for nding the minimum element By using this solution the harder problem can be solved There are multiple ways of solving the problem once we know how to nd the minimum For instance we can copy the array into a temporary array Then we nd the minimum and change its value to MAXiVALUE of type we nd the minimum again and repeat the same procedure When we nd the minimum a third time this will be third minimum in the original array Try to reach the solution by solving a harder problem Ex In order to nd the second minimum number in an array you can rst sort the array and then get the element in the second position Start from the solution and go backwards Ex If the problem is to nd a solution to the sudoku game we can start with solving the problem by hand and trying to nd the steps to go from the initial state to the nal state See httpenwikipediaorgzwikiSudoku for a description of this game Use iterativerecursive re nements Ex these techniques can be used whenever we need to perform repetitive steps to reach the solution Sorting searching are simple examples for using this technique Problem 4 Analyze design implement a solution to randomly generating siX twodigit numbers Solve the problem by parsing the random number mathematically and as a String Also show how these solutions could be created iteratively and recursively Solution Iterative mathematical parsing public static int mathParseIterative double randomNumber Mathrand0m int numbers new int6 forint i0 ilt6 i randomNumber 100 int current int randomNumber ensure that the number is a 2digit number whilecurrent lt 10 randomNumber randomNumber current randomNumber 100 current int randomNumber numbers i current randomNumber randomNumber current return numbers Recursive String parsing public static int stringParseRecursive double randomNumber Mathrandom int numbers new int6 String s randomNumber quotquotsubstring2 return stringParseRecursives 0 numbers public static int stringParseRecursiveString s int index int numbers base case if index 6 return numbers if the string is consumed before generating all 2digit numbers create a new random number and continue recursive case 1 else ifslength lt 2 double randomNumber Mathrandom s randomNumber quotquotsubstring2 return stringParseRecursives 0 numbers recursive case 2 else int current IntegerparseIntssubstring02 s ssubstring2 if current lt 10 return stringParseRecursives index numbers else numbers index current return stringParseRecursives index numbers Problem 5 Determine whether and where two squares overlap on the Xycoordinate system Assume that both squares lie horizontally Solution This will be a practice of using problem solving techniques to solve a problem We can start by solving a simpler problem Then we can extend this solution to solve the harder problem The simpler problem will be to nd if any of the sides that are parallel to the XaXis overlap Let s de ne the points for both squares lel X2y2 x5y5 X6y6 x3y3 X4y4 X7y7 X8y8 We can rst check if any of the following are the same yl and y5 y1 and y7 y3 and y5 y3 and y7 If none of these are the same the sides parallel to the X aXis do not overlap For the ones that are the same we need to check if the X intervals overlap For instance if y1 and y5 are the same there is a possibility that the top sides of the squares will overlap In order to nd that we need to check if the intervals X1 X2 and X5 X6 overlap There are 4 cases in which these overlap Xl lt X5 lt X2 lt X6 overlap in the interval X5 X2 X1 lt X5 lt X6 lt X2 overlap in the interval X5 X6 X5 lt Xl lt X6 lt X2 overlap in the interval X1 X6 3959 X5 lt Xl lt X2 lt X6 overlap in the interval X1 X2 Once we have this solution we can use the same idea to nd if the sides that are parallel to the yaXis are overlapping By solving these two simpler problems we will eventually nd all the overlapping intervals for all sides

×

×

### BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Jim McGreen Ohio University

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Amaris Trozzo George Washington University

#### "I made \$350 in just two days after posting my first study guide."

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com