Searching - CIS3023: Programming Fundamentals for CIS...

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

View Full Document Right Arrow Icon
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Searchi ng Course Lecture Slides 28 May 2010 “ Some things Man was never meant to know. For everything else, there’s Google! ”
Background image of page 1

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

View Full DocumentRight Arrow Icon
Searching Querying for something •. Searching an array for a particular value is a common problem •. Example: Where is 100 in this array? 10 1 50 2 89 10 0 55 -20 75 -10 10 A[0 ] A[1 ] A[n- 1] n=1 0
Background image of page 2
Searching Querying for something •. Searching an array for a particular value is a common problem •. Example: Where is 100 in this array? 10 1 50 2 89 10 0 55 -20 75 -10 10 A[0 ] A[1 ] A[n- 1] n=1 0 Must return location in the array (index=4)
Background image of page 3

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

View Full DocumentRight Arrow Icon
1. Let A be the array to be searched n - the number of elements k - the search target (or key) 2. Question: Does k occur in A? If k appears in A[0], A[1], …, A[n-1]: “found” determine its index i . that is, find i such that A[i] == k
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

Searching - CIS3023: Programming Fundamentals for CIS...

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

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