L24post - Previous Lecture Acoustic data frequency...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Previous Lecture: Acoustic data: frequency computation Touchtone phone Today’s Lecture: Search: Linear Search Sort: Bubble Sort and Insertion Sort Efficiency Analysis Announcements Project 6 due Monday Nov 23. StateNames.m revised W 3pm. Final exam Dec 14 (Mon) 7pm. Check for conflicts and email us ( [email protected] ) today . Specify your entire exam schedule including course numbers. Attendance in section next week is optional, but do the exercise! No office/consulting hour during Thanksgiving Break TA Chin I.’s Tues office hr moved to this Sunday 3-5pm
Image of page 1

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

View Full Document Right Arrow Icon
November 19, 2009 Lecture 24 2 Searching for an item in a collection Is the collection organized? What is the organizing scheme? Indiana Jones and the Raiders of the Lost Ark
Image of page 2
November 19, 2009 Lecture 24 3 Searching for an item in an unorganized collection? May need to look through the whole collection to find the target item E.g., find value x in vector v Linear search v x
Image of page 3

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

View Full Document Right Arrow Icon
November 19, 2009 Lecture 24 4 % f is index of first occurrence % of value x in vector v. % f is -1 if x not found. k= 1; while k<=length(v) && v(k)~=x k= k + 1; end if k>length(v) f= -1; % signal for x not found else f= k; end
Image of page 4
November 19, 2009 Lecture 24 5 % Linear Search % f is index of first occurrence % of value x in vector v. % f is -1 if x not found. k= 1; while k<=length(v) && v(k)~=x k= k + 1; end if k>length(v) f= -1; % signal for x not found else f= k; end 12 15 35 33 42 45 v x 31
Image of page 5

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

View Full Document Right Arrow Icon
% Linear Search % f is index of first occurrence % of value x in vector v. % f is -1 if x not found. k= 1; while k<=length(v) && v(k)~=x k= k + 1; end if k>length(v) f= -1; % signal for x not found else f= k; end Suppose another vector is twice as long as v. The expected “effort” required to do a linear search is … A. squared C. the same B. doubled D. halved
Image of page 6
November 19, 2009 Lecture 24 7 % Linear Search % f is index of first occurrence % of value x in vector v. % f is -1 if x not found. k= 1; while k<=length(v) && v(k)~=x k= k + 1; end if k>length(v) f= -1; % signal for x not found else f= k; end 12 15 35 33 42 45 v x 31
Image of page 7

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

View Full Document Right Arrow Icon
November 19, 2009 Lecture 24 8 % Linear Search % f is index of first occurrence % of value x in vector v.
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern