• :00Days
  • :00Hours
  • :00Mins
  • 00Seconds
A new era for learning is coming soonSign up for free
Log In Start studying!

Select your language

Suggested languages for you:
Answers without the blur. Sign up and see all textbooks for free! Illustration

Q27E

Expert-verified
Discrete Mathematics and its Applications
Found in: Page 203
Discrete Mathematics and its Applications

Discrete Mathematics and its Applications

Book edition 7th
Author(s) Kenneth H. Rosen
Pages 808 pages
ISBN 9780073383095

Answers without the blur.

Just sign up for free and you're in.

Illustration

Short Answer

The ternary search algorithm locates an element in a list of increasing integers by successively splitting the list into three sublists of equal (or as close to equal as possible) size, and restricting the search to the appropriate piece. Specify the steps of this algorithm.

The ternary search algorithm is given as:

\user1 procedure ternary search ( x1,x2,....,xn integers with n1,a integer)

v:=1 y:=m

\user1while v<y-1

Algorithm will return location , which is the position of searched element in the list.

See the step by step solution

Step by Step Solution

Step 1: Algorithm

Algorithm for Binary Search:

\user1 procedure binary search ( a : integer, x1,x2,..,xn: increasing )

i:=1{i is left endpoint of search interval}

j:=n { j is right endpoint of search interval}

\user1while i<j

Step 2: convert binary search to ternary search

Make changes in,

\user1while i<j

First change is divide using 3 instead of dividing by 2 .

The algorithm based on above conditions given as:

\user1 procedure ternary search ( x1,x2,...,xn integers with n1 ,a : integer)

v:=1y:=m

\user1while v<y-1

Recommended explanations on Math Textbooks

94% of StudySmarter users get better grades.

Sign up for free
94% of StudySmarter users get better grades.