Reputation: 1595
I have an assignment to write an algorithm to find duplicate in a Dynamic Sorted Array. I want to write this algoirthm but before starting, I must know the data structure Dynamic Sorted Array but, I dont know it. I tried to googling but I couldn't find anything like Dynamic Sorted Array. would you please guide me? What is this data structure and how dos it look like? thanks.
Upvotes: 1
Views: 146
Reputation: 38899
Let's see, you need to understand what a Dynamic Sorted array is:
You already know what a sorted array is, so let's try to understand what a dynamic array is: It's a grow able array where there is no restriction on the size of the array.
So, to summarize, you need to write an array which is:
A. Sorted
B. Dynamic in nature (expanding)
How to implement? Read Dynamic arrays overview and implementation in Java and C++
Upvotes: 0
Reputation: 3545
I think your instructor is simply referring to an array that can change and sort itself, so you can assume that it's always in the correct order and that it is of variable length. If the algorithm is to be written in pseudo-code that's probably all you need to know.
Upvotes: 1
Reputation: 3735
I would say you may have a typo in your assignment. It might ought to read "sorted Dynamic Array".
However, a dynamic array which always inserts new items in sorted order would probably fit that terminology. So take your dynamic array:
[2][5][7][9]
Inserting the element '8' would result in the following array:
[2][5][7][8][9]
Upvotes: 0
Reputation: 41617
I never heard of that data structure, but based on the individual words I would guess that it:
get(index)
and set(index)
.I don't think though that such a data structure is very efficient for finding duplicates. I would prefer some sort of map, unless you need very simple algorithms.
Upvotes: 0
Reputation: 272467
I assume it means an array whose length is dynamic (i.e. unknown at compile-time), and whose values are sorted.
Upvotes: 0