You are here:

C++/ordered list implementation in c++


can u plzz guide me with code for getting length of ordered but unsorted array in c++ in O(n) time complexity also plzz tel how to print and retrieve element from this in same O(n) time

Dear maria:

To get the length of an array you can just check the length you specified it to be or you can traverse the array until you get the the end (e.g. A [ i ] = null).

The only way to print data from an array in O ( n ) time is to traverse the array printing its elements either from start to finish of from a specified element to another.  If you want to print specific data you will have to note where that data is in the array and save it first and last element.  Then you can just print from the first to the last element.


All Answers

Answers by Expert:

Ask Experts


Titus B. Ledbetter, Jr.


C , MFC, Object Oriented, Artificial Intelligence


I have over ten years experience in the field of Computer Science, five years experience developing C/C++. I recently wrote a chess program using Object Oriented, C++, MFC.

Master's Degree Computer Science from Johns Hopkins

©2016 All rights reserved.