Solved

Algorithms

Posted on 2001-09-14
4
418 Views
Last Modified: 2008-03-06
How can I give an example of an algorithm that is

O(1) - bounded (by a constant)time

O(N)- linear time

O(N2) - quadratic time
0
Comment
Question by:quietstorm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6483387
Is this homework?

It is against EE policy for experts to do homework questions.
We can help you with code that you have already done, but we can not give you full answers.

Please attempt to do part of the work, and then ask a specific question when you get stuck.
0
 
LVL 2

Expert Comment

by:sateesh_babu
ID: 6485614
Just go thru some Data Structures Book, may be Horowitz & Sahani will help. You have all the answers you want there.

Babu
0
 

Accepted Solution

by:
kirsh earned 50 total points
ID: 6486908
Hi,

O(1) : Constant = PRINT "A"
                  PRINT "B"

O(N) : A loop = READ N
                FOR I=1 TO N DO
                     PRINT "N"

O(N2) : A loop inside a loop = READ N
                               READ L
                               FOR I=1 TO N DO
                                   FOR I=1 TO L DO
                                       PRINT "L"

This is pseudo-code of course.

Naftali Kirsh.
0
 
LVL 5

Expert Comment

by:proskig
ID: 6487074
>How can I give an example of an algorithm that is

Yes, you can. Give us some...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question