answersLogoWhite

0


Best Answer

Arrays are the most efficient data structure. Memory is allocated to the entire array as a single operation and the total memory consumed is equal to the product of the element size and the number of elements (all elements being of equal size, in bytes). This means that any element in the array can be accessed using simple pointer arithmetic from the start of the array, with the first element at offset 0. All high level languages hide the pointer arithmetic behind an array suffix operator, such that element [5] will be found 5 * sizeof (element) bytes from the start address of the array (the address where element [0] resides). Multi-dimensional arrays are implemented as an array of arrays, such that a two-dimensional array is a one-dimensional array where every element is itself a one-dimensional array. These can be thought of as being a table of rows and columns where the first dimension access a one-dimensional row array, and the second dimension accesses the column within that row. A three-dimensional array can then be thought of as being an array of tables or a cuboid (a stack of tables). A four-dimensional array can therefore be thought of as being an array of cuboids, a table of tables, or a cuboid of arrays. By imagining arrays in this manner it becomes much simpler to imagine arrays with more than 3 dimensions.

By contrast, a list or a tree structure is less efficient because every element requires at least one additional field to maintain the link from that element to another element, thus defining the structure. You also need to maintain an additional field to refer to the first element in the structure. If you have a structure that can dramatically vary in size, lists may be more efficient because there is no need to reallocate the entire structure; you simply allocate and deallocate memory for individual elements and update the links between elements to maintain the structure. However, you lose constant-time random access because you have to traverse the links in the structure to locate an individual element and the additional level of indirection means it will be slower than an array. However, reallocating an array often means copying the array to new memory. One way to minimise reallocations is to reserve more memory than you actually need, thus allowing you to add new elements more quickly at the cost of some memory. You only need to reallocate when you run out of reserve. You can also minimise the cost of reallocation by storing pointers rather than objects in your array. This adds an extra level of indirection, but speeds up the reallocation process by only copying pointers rather than objects being pointed.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

The key characteristic of a priority queue is that elements in the queue must be ordered in some way, such that elements with higher priority move to the front of the queue more quickly than those with lower priority. As such, the most appropriate data structure for a priority queue is a heap, yielding O(1) extraction time and O(log n) insertion time.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

Storage classes are not intended for efficiency, they are storage duration specifiers intended to define or refine the scope, visibility and lifetime of a variable.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

struct

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Heap

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the most appropriate datastructure to implement priority queue?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is most appropriate data structure to implement priority queue?

heap


Minimum number of queues needed to implement the priority queue?

Separated queue for every possible priority value.


How many minimum no of queues Rae needed to implement priority queue?

Two possible solutions: 1. Separated queue for every possible priority value. 2. One shared queue for every elements, sorted by priority.


What is the difference between a priority queue and a circular queue?

A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. A priority queue is a queue in which each element is inserted or deleted on the basis of their priority. A higher priority element is added first before any lower priority element. If in case priority of two element is same then they are added to the queue on FCFS basis (first come first serve).


What are the difference between ascending priority queue and descending queue?

Ascending priority queue is a collection of items which can be inserted aurbitarly and which can be removed smallest item. Descending priority queue is similar to ascending priority queue but it allows the deletion of the largest item.


Array implementation of priority queue?

the priority queue is which depends on the data stored.in which their priority is maintained by checking the forth coming values stored in the queue


What are the different types of queues?

A priority queue is a queue in which each element is inserted or deleted on the basis of their priority. A higher priority element is added first before any lower priority element. If in case priority of two element is same then they are added to the queue on FCFS basis (first come first serve). Mainly there are two kinds of priority queue: 1) Static priority queue 2) Dynamic priority queue


Queue ADT Using Array?

implement the queue ADT using an array


What is priority queue?

A priority queue is a collection of elements that each element has been assigned a priority and such that order in which elements are deleted and processed comes from the following riles: 1) An element of higher priority is processed before any element of lower priority. 2) Two element with the same priority are processed according to the order in which they were added to the queue.


Explai the nature of the various types queues in data structures?

The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer. A priority queue is a queue in which each element is inserted or deleted on the basis of their priority. A higher priority element is added first before any lower priority element. If in case priority of two element is same then they are added to the queue on FCFS basis (first come first serve). Mainly there are two kinds of priority queue: 1) Static priority queue 2) Dynamic priority queue A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion)


What are types of Queue?

Queue is a data structure which is based on FIFO that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )


How do you implement a FIFO structure?

FIFO is a first-in, first out structure. In other words, it is a queue. The most efficient way to implement a queue is with a circular array.