answersLogoWhite

0

manu_del In Probability Search , the list is ordered with most probable search element at the beginning of the list and least probable at the end.

Useful when a relatively small number of elements are the targets for most of the searches. To ensure that the probability ordering is correct over time, in each search we exchange the located element with the element immediately before it in the list.

This is a sample ProbabilitySearch program for a list of integers

INPUT:

list[] : reference of integer array

last : index of last item

target: target to be found

ref_locn: reference to the location of target

OUT:

If target is found

location of target is stored in ref_locn

found = 1 is returned

target is moved up in priority

Else

last is stored in ref_locn

found = 0 is returned

int ProbabilitySearch (int list[],int last, int target, int *ref_locn)

{

int looker = 1;

int found = 0;

int temp;

while(looker <= last && target != list[looker])

{

looker = looker + 1;

}

if(target == list[looker])

{

found = 1;

if(looker > 1)

{

temp = list[looker -1];

list[looker -1] = list[looker];

list[looker] = temp;

looker = looker -1;

}

}

else

found = 0;

*ref_locn = looker;

return found;

}

User Avatar

Wiki User

7y ago

What else can I help you with?

Related Questions

What data structure and logarithm?

data structure is a way of storing data in a computer so that it can be used efficientlyan algorithm is a sequence of instructions, often used for calculation and data processing.Often a carefully chosen data structure will allow the most efficient algorithm to be used.


What is a high speed data searching and sorting in data structure algorithm?

Binary Search is the high speed data searching.Here in each recursion the is divided in two equal halves so that execution becomes easier.


How do you print all data in a Binary Search Tree?

By using Depth First Search or Breadth First search Tree traversal algorithm we can print data in Binary search tree.


What is the difference between allocation and search data structure?

difference between serch data structure and allocation data structure


How does the nesting algorithm work to organize and structure data efficiently?

The nesting algorithm organizes and structures data by grouping related items together within a hierarchical structure. This helps to efficiently store and access the data, as items are organized based on their relationships to one another.


Write a algorithm for a deque operations?

please read data structure (schaum series) books


What is the time complexity of Dijkstra's algorithm when using a priority queue data structure?

The time complexity of Dijkstra's algorithm with a priority queue data structure is O((V E) log V), where V is the number of vertices and E is the number of edges in the graph.


What is structure of maem?

&quot;MAEM&quot; is likely referring to the MEEG algorithm Error Message Format (MAEM). It is a data structure used in error reporting for algorithm-related error messages in the MEEG algorithm. The structure of MAEM typically consists of error codes, descriptions, and other relevant information to help users identify and troubleshoot issues with the algorithm.


What is the purpose and functionality of the randomized select algorithm in the context of sorting and selecting elements in a data structure?

The purpose of the randomized select algorithm is to efficiently find the kth smallest element in an unsorted list. It works by randomly selecting a pivot element, partitioning the list around that pivot, and recursively narrowing down the search space until the kth element is found. This algorithm is useful for selecting specific elements in a data structure without having to sort the entire list.


How can the Breadth-First Search (BFS) algorithm be implemented using recursion?

The Breadth-First Search (BFS) algorithm can be implemented using recursion by using a queue data structure to keep track of the nodes to visit. The algorithm starts by adding the initial node to the queue and then recursively visits each neighbor of the current node, adding them to the queue. This process continues until all nodes have been visited.


How can Dijkstra's algorithm be implemented in Java using a heap data structure for efficient shortest path calculations?

Dijkstra's algorithm can be implemented in Java using a heap data structure to efficiently calculate the shortest path. The heap data structure helps in maintaining the priority queue of vertices based on their distances from the source node. By updating the distances and reorganizing the heap, the algorithm can find the shortest path in a more optimized way compared to using other data structures.


What is the worst case and best case for binary search?

The best case for a binary search is finding the target item on the first look into the data structure, so O(1). The worst case for a binary search is searching for an item which is not in the data. In this case, each time the algorithm did not find the target, it would eliminate half the list to search through, so O(log n).