Wrox Programmer Forums
|
BOOK Programming Interviews Exposed: Secrets to Landing Your Next Job 2nd Ed ISBN: 978-0-470-12167-2
This is the forum to discuss the Wrox book Programming Interviews Exposed: Secrets to Landing Your Next Job, 2nd Edition by John Mongan, Noah Suojanen, Eric Giguère; ISBN: 9780470121672
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK Programming Interviews Exposed: Secrets to Landing Your Next Job 2nd Ed ISBN: 978-0-470-12167-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2011, 12:15 AM
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Big-O Analysis Example

Hi All,

I'm working through one of the examples in the Big-O Analysis section, in which they analyze the CompareToAll implementation that returns the largest integer in an array. The book states:

"For now, assume that the maximum element is at the end of the array. In this case, this function may compare each of n elements to n other elements. Thus, there are n ( n examinations, and this is an O( n 2 ) algorithm."

However, the outer for loop checks the end of the array first, so wouldn't the inner loop just run through once before the method breaks out of the outer for loop, making it just n examinations?

Thanks for helping me clarify this!
 
Old July 23rd, 2011, 10:14 AM
Authorized User
 
Join Date: May 2011
Posts: 15
Thanks: 11
Thanked 0 Times in 0 Posts
Default Chapter 3, p. 22, of 2nd edition

Yes, you're right, as I see it.

This idea could be better expressed in a future edition. Instead of writing "at the end of the array", it would be better to write "the last element to be examined by the algorithm: here it would be the element at index zero".

Hope this helps!

Wayne





Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you use Analysis Services? valiko_work SQL Server 2005 0 August 10th, 2007 05:41 AM
Further analysis migake XSLT 3 November 6th, 2006 07:13 PM
Crystal Analysis SaralaManoharan Classic ASP Professional 0 December 21st, 2005 08:36 AM
Analysis Manager ColdFusionRO SQL Server 2000 1 July 25th, 2003 05:39 PM
TOP N Analysis rj SQL Server 2000 1 July 13th, 2003 10:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.