## Example of binary search, Data Structure & Algorithms

Assignment Help:

Let us assume a file of 5 records that means n = 5

And k is a sorted array of keys of those 5 records. Let key = 55, low = 0, high = 4

Iteration 1: mid = (0+4)/2 = 2 k(mid) = k (2) = 33

Now key > k (mid)

Thus low = mid + 1 = 3

Iteration 2: low = 3, high = 4 (low <= high)

Mid = 3+4 / 2 = 3.5 ~ 3 (integer value)

Here key > k (mid)

Thus low = 3+1 = 4

Iteration 3: low = 4, high = 4 (low<= high)

Mid = (4+4)/2 = 4

Here key = k(mid)

Thus, the record is at mid+1 position that means 5

#### Explain thread, Thread By changing the NULL lines in a binary tree to ...

Thread By changing the NULL lines in a binary tree to special links known as threads, it is possible to perform traversal, insertion and deletion without using either a stack

#### Nothing, c++ To calculate the amount to be paid by a customer buying yummy ...

c++ To calculate the amount to be paid by a customer buying yummy cupcakes for his birth day party

#### Maximum degree of any vertex in a simple graph, The maximum degree of any v...

The maximum degree of any vertex in a simple graph with n vertices is (n-1) is the maximum degree of the vertex in a simple graph.

#### CREATING ENSEMBLE NEERAL NETWORK, HOW DO I CREATE ENSEMBLE NETWORK IN MATLA...

HOW DO I CREATE ENSEMBLE NETWORK IN MATLAB

#### Graphs, In this unit, we will describe a data structure called Graph. Actua...

In this unit, we will describe a data structure called Graph. Actually, graph is a general tree along no parent-child relationship. In computer science, Graphs have several applica

#### Sparse matrix, Q. Define a sparse matrix. Explain different types of sparse...

Q. Define a sparse matrix. Explain different types of sparse matrices? Show how a triangular array is stored in memory. Evaluate the method to calculate address of any element ajk

#### Queue, algorithm for insertion in a queue using pointers

algorithm for insertion in a queue using pointers

#### Explain the method of overlapping and intersecting, Overlapping or Interse...

Overlapping or Intersecting A polygon overlaps or intersects the current background if any of its sides cuts the edges of the viewport as depicted at the top right corner of th

#### Explain the array and linked list implementation of stack, Question 1. ...

Question 1. How can you find out the end of a String? Write an algorithm to find out the substring of a string. 2. Explain the insertion and deletion operation of linked lis  