hw-1-control-flow

hw-1-control-flow - int bott, top, mid ; bott = 0 ; top =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 of 2 Homework 1 To: CSci 5802, All students CC: Teaching Assistant From: Dr. Mats Heimdahl Date: 1/31/2010 Re: Homework Assignment 1 – Control Flow (Individual Assignment) The problems Problem 1 Below you will find a simple search procedure (Binary Search) that takes an element (key), an array (T), and the size of the array (size) as input arguments. Draw the control flow graph for the program. void Binary_search (elem key, elem[] T, int size, boolean &found, int &L) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int bott, top, mid ; bott = 0 ; top = size -1 ; L = ( top + bott ) / 2 ; found = false ; if (T[L] == key) found = true ; while (bott <=top && !found) { mid = (top + bott) / 2 ; if ( T [mid] == key ) { found = true; L = mid ; } else if (T [mid] < key ) bott = mid + 1 ; else top = mid-1 ; } // while } //binary_search January 31, 2010 2 of 2 Problem 2 Do problem 5.7 in the testing book. Due Date Note: Individual Assignment. Monday, February 8 in class....
View Full Document

This note was uploaded on 10/21/2011 for the course CSCI 5802 taught by Professor Heimdahl,m during the Spring '08 term at Minnesota.

Page1 / 2

hw-1-control-flow - int bott, top, mid ; bott = 0 ; top =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online