473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Time analysis

hello,

i have a question regarding time analysis, respectively calculating the
Big O. For example when i have this function:

Expand|Select|Wrap|Line Numbers
  1. void sequence::attach(const value_type& entry)
  2. {
  3. if(!(is_item()))
  4. {
  5. cursor = tail_ptr;
  6. }
  7.  
  8. if(cursor == NULL)
  9. {
  10. list_head_insert(head_ptr, entry);
  11. cursor = head_ptr;
  12. tail_ptr = head_ptr;
  13. }
  14. else
  15. {
  16. list_insert(cursor, entry);
  17. precursor = cursor;
  18. cursor = cursor->link();
  19. }
  20.  
  21. ++many_nodes;
  22.  
  23. node* cursor1;
  24. node* precursor1;
  25. for(cursor1 = head_ptr; cursor1 != NULL; cursor1 = cursor1->link())
  26. {
  27. precursor1 = cursor1;
  28. }
  29. tail_ptr = precursor1;
  30. }
  31.  
Does there exist an easy concept how i can calculate the Big O for the
previous function for example...?

matti

Oct 25 '06 #1
1 1465
ma****@gmx.at wrote:
hello,

i have a question regarding time analysis, respectively calculating the
Big O. For example when i have this function:

Expand|Select|Wrap|Line Numbers
  1. void sequence::attach(const value_type& entry)
  2. {
  3.     if(!(is_item()))
  4.     {
  5.         cursor = tail_ptr;
  6.     }
  7.     if(cursor == NULL)
  8.     {
  9.         list_head_insert(head_ptr, entry);
  10.         cursor = head_ptr;
  11.         tail_ptr = head_ptr;
  12.     }
  13.     else
  14.     {
  15.         list_insert(cursor, entry);
  16.         precursor = cursor;
  17.         cursor = cursor->link();
  18.     }
  19.     ++many_nodes;
  20.     node* cursor1;
  21.     node* precursor1;
  22.     for(cursor1 = head_ptr; cursor1 != NULL; cursor1 = cursor1->link())
  23.     {
  24.         precursor1 = cursor1;
  25.     }
  26.     tail_ptr = precursor1;
  27. }
  28.  

Does there exist an easy concept how i can calculate the Big O for the
previous function for example...?
First, this is not a C++ *language* question and so is off-topic here
(see http://www.parashift.com/c++-faq-lit....html#faq-5.9).
You should ask in comp.programming or similar.

Second, we're not here to do your homework for you
(http://www.parashift.com/c++-faq-lit....html#faq-5.2).

I can tell you that the standard C++ linked list is O(1) to insert and
O(N) to traverse (cf. http://www.sgi.com/tech/stl/List.html).

Cheers! --M

Oct 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gary N | last post by:
Sr. Database Administrator Permanent Position/Pittsburgh Pa $70-95K with full benefits Description A client of A.C.Coy's is looking for a Senior Database Administrator to join their team on a...
5
by: Ray Tomes | last post by:
Hi Folks I am an old codger who has much experience with computers in the distant past before all this object oriented stuff. Also I have loads of software in such languages as FORTRAN and...
3
by: Tim_Mac | last post by:
hi, i'm generating PDF files from crystal reports in my .Net 1.1 web site, and saving them to disk for the user to download in their own time. the format i'm currently using is: ...
6
by: Aussie Rules | last post by:
Hi, I have a datepicker that show a calender. The user picks a date and the time component is always 00:00. I then have a drop down that provides a list of times, (10:00, 11:00 etc), and I...
4
by: kwatch | last post by:
Hi, I have a question about os.times(). os.times() returns a tuple containing user time and system time, but it is not matched to the result of 'time' command. For example, os.times() reports...
2
by: Roseanne | last post by:
We are experiencing very slow response time in our web app. We run IIS 6 - windows 2003. I ran iisstate. Here's what I got. Any ideas?? Opened log file 'F:\iisstate\output\IISState-812.log'...
1
by: | last post by:
How do you debug the design time behavior of user controls? I have code in the controls resize event and I've flagged a break point, but the code never breaks when I play with the control on the...
0
by: Johannes Nix | last post by:
Hi, this might be of interest for people who are look for practical information on doing real-time signal processing, possibly using multiple CPUs, and wonder whether it's possible to use...
3
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I want to limit the user only login the system one time at the same time. I don't want him login the system two with the same user at the same time. How to do this? If i have a table to record...
27
by: CodeMonk3y | last post by:
gotta question on sizeof keyword does the sizeof keyword calcuates the size at compile time or run time ?? -- Posted on news://freenews.netfront.net - Complaints to news@netfront.net --
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.