Solved

Algorithms

Posted on 2001-09-14
4
417 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

829 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