Here are my questionsand my answers. Could you guys/gals tell me if i am right or wrong?
Which array-based operations are O(1)?
inserting item or deleting item in unsorted array

Which linked-list operations are O(1)?
inserting and deleteing item in unsorted lsit

Which array-based operations are O(n)?
traversing through the list or adding or deleting in a sorted array

Which linked-list operations are O(n)?
traversing through the list or adding or deleting in a sorted list

so what do you think i am right or wrong or is there anything else?

Recommended Answers

All 2 Replies

>>Which array-based operations are O(1)?
>>inserting item or deleting item in unsorted array

not quite, what happens if we insert in the middle of the array. How about accessing the data?

>>Which linked-list operations are O(1)?
>>inserting and deleteing item in unsorted lsit
true.

>>Which array-based operations are O(n)?
>>traversing through the list or adding or deleting in a sorted array
its asking you about arrays, why are you mentioning lists?
Whats the difference from "adding" in an array then "inserting" in an array?
In general, inserting and deleting can take up O(n).

>>Which linked-list operations are O(n)?
traversing through the list or adding or deleting in a sorted list
true.

thanks bro i got it now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.