B TREE Algorithm Complexity Analysi
B TREE Algorithm Complexity Analysi
251 – 263
DOI 10.2478/jaiscr-2014-0018
Abstract
This paper presents a comparative analysis of complexity between the B-TREE and the
Binary Search Algorithms, both theoretically and experimentally, to evaluate their effi-
ciency in finding overlap of classes for students and teachers in the University Course
Timetabling Problem (UCTP). According to the theory, B-TREE Search complexity is
lower than Binary Search. The performed experimental tests showed the B-TREE Search
Algorithm is more efficient than Binary Search, but only using a dataset larger than 75
students per classroom.
To find a good solution to UCTP using any the efficiency of the search algorithms applied to
metaheuristic, local search application is necessary. this specific case.
The heart of a local search is the application of a The contribution of this work is to find the most
neighborhood structure, which generates exchanges efficient search algorithm to detect overlap of events
of elements. Iterative local search, guided by an for students and teachers in the UCTP.
objective function, can improve the solution of a
problem as UCTP, but every swap generated by the The present research is divided as follows. Sec-
neighborhood structure through local search could tion one provides a general introduction to the
generate an unfeasible solution. To detect a move- problem, and emphasizes the importance of having
ment of the neighborhood structure that can gener- an efficient method which can obtain good solu-
ate an unfeasible solution in UCTP, it is necessary tions in a reasonable computational time. Section
to use a search algorithm. For example, in a UCTP, two presents the formal definition of the Univer-
moving a student e to take a class on day i, at a sity Course Timetabling Problem, focusing on the
specific hour j, in classroom k, (i, j, k), may cre- explanation of the set of constraints, which define
ate schedule conflicts (overlap) for the student and the specific case. Section three discusses the theo-
other classes that he takes. To determine if there retical complexity managed in the literature for the
is overlap, it is necessary to perform a search in all principal search methods. An explanation is given
classrooms (k = 1,..., n) to verify that the student e for the methods of both Binary Search and B-TREE
is not taking another class in the same timeslot (i, Search. The fourth section presents the temporal
j). functions specified to each algorithm. Section five
shows the experimental results, and the compara-
According to theory, the search algorithms with tive analysis of both methods, taking into account
the least theoretical complexity are B-TREE and their theoretical and experimental complexity. Fi-
Binary search. The B-TREE complexity, in the nally, the conclusions of this research are presented
worst case, is lower than the Binary search com- in section six.
plexity. For this reason, in this work, these two
search algorithms were tested for UCTP. A set of
hard constraints were accounted for, which ensured 2 University Course Timetabling
non-overlapping classes for both teachers and stu- Problem
dents [5]. The fulfillment of these constraints must
be verified; it is necessary to check that students do The University Course Timetabling Problem
not take more than one subject per timeslot (i, j), (UCTP) has been classified within the Complexity
and in one classroom k. If a student e takes more Theory as NP-Complete [1]. This problem could be
than one subject in the same timeslot (i, j), the stu- solved by deterministic or non-deterministic meth-
dent is overlapping; therefore, the obtained solution ods. Using a deterministic method, it is only fea-
is unfeasible. sible to obtain the optimal solution for a small in-
In this research, the two most efficient search al- stance, because if the instance size grows, the com-
gorithms, according to their theoretical complexity, putation time of a deterministic algorithm increases
were used to conduct an experimental comparison. exponentially. As a result, most researchers have
focused on heuristics, which get approximated so-
Application of a search method allows for re-
lutions in a reasonable time; although, there is no
vision of each student e assigned to an event in a
guarantee of their optimality.
timeslot in a CR classroom. It also allows for revi-
sion of possible overlaps with other events the stu- The features of the components that are consid-
dent takes, where an event is a class taken by the ered in this problem, such as students, classrooms,
student e. According to this reasoning, the meth- facilities, teachers, and classes, when considered in
ods applied to UCTP require a very efficient search combination with the features of limited resources,
algorithm within their structure due to the iterative time considerations and the available spaces for as-
nature which is required for this problem. Accord- signing the events, make it difficult to get feasible
ing to theoretical and experimental results, a con- solutions in a reasonable computing time.
clusion was reached as to the best option, based on
B-TREE ALGORITHM COMPLEXITY ANALYSIS TO . . . 253
The goal of finding solutions to the UCTP is all the students assigned to attend the event.
to obtain a scheduling such that both students and H3. The assigned classroom must have the required
teachers can attend all their programmed classes facilities to carry out the assigned event.
without time difficulties. The UCTP has some spe-
cific features that must be respected to obtaining a H4. No classroom can have more than one event in
feasible solution. These features are known as con- the same timeslot.
straints, and are classified into two kinds of con- H5. No teacher attends more than one event in the
straints. same timeslot.
Hard Constraints: They must be fulfilled com- Set of Soft Constraints
pletely, and must not be violated. For example a S1. A student should not take classes in the last
teacher cannot give different classes in the same timeslot of the day.
timeslot.
S2. A student should not take two or more uninter-
Soft Constraints: They should, preferably, be sat- rupted classes.
isfied, although some violations could be accepted
adding a penalty per each violation. A clear exam- S3. A student should not take only one class during
ple may be that the students should not have four or a day.
more continuous classes. The main reason is that The UCTP could be represented in a schematic
it is not pedagogically recommended, because the form (Figure 1) to improve its understanding.
students need a rest after taking continuous classes.
The representation shown in Figure 1 is made
However, some violation could be accepted due to
using a tridimensional form, better known as a cube,
the time circumstances, and the scheduling.
where each layer, represented by different colors,
The specific problem tackled in this research symbolizes a classroom. A classroom is formed by
consists of a set of events that have to be pro- several 3D boxes (Period, Day, and Classroom) per
grammed in a set of 45 timeslots, which are dis- day, where each one defines a timeslot where an
tributed in five days with nine 50-minute periods event can be assigned. An event is the intersection
per day. There is also a set of classrooms where between a Period, and a Day in certain Classroom,
the events are held, a set of students who attend where an event could be assigned. Each event will
the events, and a set of facilities in each classroom, be taken by a group of students, who will attend to
which are necessary to perform the events. Each several events {EV1, EV2,. . . , EVn} per week. For
student has to attend a certain number of events, example, the EV1 is taken by students E1, E2, and
which are scheduled in certain classrooms with spe- E3 in the classroom CR2. A set of events form a
cific features. Taking this into account, a feasible class.
solution has to have all the events scheduled in a
Each classroom has certain features, which are
classroom during a timeslot, respecting the follow-
required by the different events. Those features
ing constraints and trying to improve the value of
could be TVs, DVDs, computers, projectors, or
the objective function (1).
whiteboards, among others.
Some of the characteristics that must be taken
Min F.O = ∑ s1 + ∑ s2 + ∑ s3 (1) into account to assign an event to a classroom are
its features and size. For example, a mathematics
The objective function minimizes the quantity
teacher may need a whiteboard in order to give a
of soft constraints violated, where S1, S2, and S3
class. Size of the classroom must also be consid-
refer to the soft constraints defined to this specific
ered. It is necessary to check the classroom capac-
problem [6]. The constraints, both hard and soft,
ity because a common problem is that big groups of
are explained as follows:
students are assigned to small classrooms. In Figure
Set of Hard Constraints 1 we can observe a possible solution, where all the
H1. No student attends more than one event in the hard and soft constraints are satisfied in order to get
same timeslot. a feasible scheduling to a small instance. For this
representation, the quality of the obtained solution,
H2. The classroom capacity must be enough to hold
254 Cruz Chvez M. A., Martnez Oropeza A.
according to the objective function is not evaluated, amination of their theoretical complexity allowed
because it is only an example of a feasible solution for the selection of the two best algorithms. An
where all the constraints are satisfied. It is very dif- experimental comparison was performed, using a
ficult to use a bigger instance because of its time computer program to select the best algorithm for
limitations and the nature of the problem. this specific problem.
3 Search Algorithms
Search algorithms have been widely used to
perform searches in data structures, such as trees,
where they have been applied successfully. Many
types of search algorithms exist, such as linear
search, Binary search, B-TREE search, and some
hybrid searches, which have been applied to differ-
ent optimization problems.
The main difference among these search algo-
rithms is the computational effort required to carry
out a certain search, because many of them need
the keys (elements of the total set) in a specific or-
der, which increases the complexity of the algo-
rithm. For this research, three of the most com-
mon search algorithms are used, in addition to one
hybrid (Quicksort + Binary search). According to
their complexity, theoretically, B-TREE search is
more efficient that the others.
The complexity of an algorithm (Table 1) de-
pends on the number of questions that it must ask in
the worst case in order to find a specific key within
a set of n keys.
Using the information from Table 1, the graph
Figure 1. Schematic representation of a possible below (Figure 2) was made, which clearly shows
solution applied to a small UCTP instance the theoretical behavior of each search method. In
the case of B-TREE search, a tree to the order of 5
Finding a feasible solution is not easy; it re-
was used.
quires an efficient process dedicated to exploring
the solution space and verifying that all the con- According to the comparison presented in Table
straints were satisfied. The process of ensuring that 1 and Figure 2, it can be observed that the most ef-
a solution is feasible requires the use of a search al- ficient algorithm is B-TREE search, and the second
gorithm, which has to examine each set of students most efficient is Binary search. It is important to
and teachers in each classroom to make certain that note that these two algorithms work with ordered
no subject and no students were overlapped. Even keys. They have the previously mentioned com-
if a feasible solution is found, it is necessary to con- plexity only if the set of keys used are already or-
tinue exploring for new feasible solutions in order dered; otherwise, the complexity increases depend-
to obtain the best possible solution. The aim of the ing on the sorting algorithm applied.
present research is to find an efficient search algo- A comparison of the requirements of the search
rithm to apply to the specific problem of UCTP ex- algorithm (Table 1) with the features of the specific
plained in this section. problem tackled in this paper, show that it is pos-
The next section provides a general explanation sible to apply them to the UCTP. The set of keys
of some of the most efficient search algorithms. Ex- used corresponds to the students assigned to differ-
B-TREE
B-TREE
ALGORITHM
ALGORITHM
COMPLEXITY
COMPLEXITY
ANALYSIS
ANALYSIS
TO . . .TO . . . 255
TableTable
1. Theoretical
1. Theoretical
complexity
complexity
in theinworst
the worst
case for
casefour
for commonly
four commonly
used used
searchsearch
algorithms
algorithms
Search
Search
Algorithm
Algorithm Theoretical
Theoretical
Complexity
Complexity
( n+1 )( n+1 )
B-TREE
B-TREE m > 2m > 2 dmin
dmin = log= log+m1)
m (n (n d+max
1) =
dmax
1 +=log
1+ log)( m+1
( m+1 2) 2
2 2
Binary
Binary
Search
Search iterations
iterations
= log= log2 (n)
2 (n)
Linear
Linear
Search
Search iterations
iterations
=n =n
QuickSort
QuickSort
+ Binary
+ Binary
Searchc
Searchc
= 3.321928095
= 3.321928095 iterations
iterations
= log= (nn+c
10 log ) n+c )
10 (n
Binary Search
256 Cruz Chvez M. A., Martnez Oropeza A.
ent events. Those data are always ordered, thus a bound (Equation 3) of a B-TREE with D = 1. It has
sorting algorithm is not needed and the algorithms three pointers (m = 3) and two keys per node (2D =
maintain their theoretical complexity. For this rea- 2), giving a depth of three (LB = 3) and n = 26 keys.
son, the two most efficient algorithms were chosen The depth is very important because is the number
which are, according to Table 1, the Binary search of iterations required to find the sought key.
and B-TREE algorithms are. Applying Equation 4, the upper bound of the
Binary Search same B-TREE can be obtained. The result is a B-
This type of search works with a set of ordered keys, TREE with four levels. In the same way, a balanced
which divides in two parts and compares a sought tree is obtained, which is shown in Figure 4. It is
key with the central one. If it is not equal, the limits not complete because it does not use the maximum
of the rank are defined, depending on whether the number of pointers per node.
central key is greater or less than the sought one, The levels vary, due to the handling of balanc-
which considerably reduces the search set. This ing, and how the keys are accommodated into the
process is performed iteratively until the sought key nodes. For example, in Figure 2, the maximum
is found. Binary search always finds the sought key number of pointers per node is used. This is unlike
if it exists. The worst case would be that the desired Figure 4, where the nodes do not use all their keys,
key would be the last one compared. Consequently, and most of them have only two pointers, which in-
Fig. 4. Upper Bound of a B-tRee order three, incomplete and balanced.
the number of iterations would be defined by (2), creases the levels of the tree (UB = 4.75).
where the number of iterations is directly affected
the levels vary, due to the handling of balancing, and how the keys are accommodat-
by the number of keys in the sample. ed into the nodes. for example, in figure 2, the maximum number of pointers per
node is(2)
4 Binary and B-TREE Search Al-
used. This is unlike Figure 4, where the nodes do not use all their keys, and
iterations = log2 (n)
most of them have gorithms
only two pointers, which increases the levels of the tree (UB =
B-TREE Search 4.75).
The two algorithms explained in the last sec-
B-TREE search performs a specific search for a tion were programmed using C standard language.
4 makes
key in a balanced tree. This type of search Binary and B-TREE Search Algorithms
Before the experimental testing, a complexity anal-
a multi-way branching decision according to the ysis of both algorithms was performed, obtaining
The two algorithms explained in the last section were programmed using C standard
number of children per node (order). As input, B-
language. Before the experimental testing, a complexity analysisalgo-
their temporal function in the worst case. The of both algorithms
TREE search takes a pointer to the root node and
was performed,rithms’ programs
obtaining are shown
their temporal below
function (Figure
in the worst 5, andthe algorithms’
case.
searches for a key in a sub tree [10]. programs are shown
6). below (figure 5, and 6).
According to this, a B-TREE of order D can store
up to 2D keys in each of its tree nodes, with a max-
imum of 2D + 1, which corresponds to the maxi-
mum number of children per node. This is true for
all nodes, except the root node, which could have
at least one key, and as a result two pointers [8].
Therefore, the depth d is between a lower (LB) and
an upper bound (UB), which are defined by equa-
tions 3 and 4 [9].
LB = logm (n + 1) (3)
Figure
Fig.5.
5. Binary search
Binary search algorithm
algorithm
( )
n+1 The Binary search inalgorithm presented in Fig-of checking the
UB = 1 + log( m+1 ) the Binary
(4) search algorithm presented Figure 5 shows the process
2 2 feasibility of the
uresolutions
5 showsin the
a general
process way.
of first of all,the
checking the feasibil-
function receives some
parameters; theity
first
ofone
thecontains
solutionstheinarray of students
a general way.orFirst
teachers (keys) assigned to
of all,
In equations 3 and 4, m = 2D + 1 indicatesdifferent
the totalevents in a timeslot (i, j), which have to be carefully checked in each class-
the function receives some parameters; the first one
number of pointers per node in the tree, and n isof
room thethe same timeslot (i, j) to avoid overlaps. the second one contains the num-
contains the array of students or teachers (keys) as-
number of keys in the tree. A graphical representa-
signed to different events in a timeslot (i, j), which
tion is shown in Figure 3, and is based on the lower
children per node. This is true for all nodes, except the root node, which could have at
least one key, and as a result two pointers [8]. Therefore, the depth d is between a
lower (LB) and an upper bound (UB), which are defined by equations 3 and 4 [9].
LB log m n 1 (3)
B-TREE ALGORITHM COMPLEXITY ANALYSIS TO . . .
n 1 257
UB 1 log m1 (4)
2
2
Figure equation
Applying 3. Lower4,Bound
the upper
of abound of the
B-TREE samethree,
order B-tRee can beand
complete obtained. the
balanced
result is a B-tREE with four levels. In the same way, a balanced tree is obtained,
which is shown in Figure 4. It is not complete because it does not use the maximum
number of pointers per node.
The two algorithms explained in the last section were programmed using C standard
language. Before the experimental testing, a complexity analysis of both algorithms
was performed, obtaining their temporal function in the worst case. the algorithms’
programs are shown below (figure 5, and 6).
258 Cruz Chvez M. A., Martnez Oropeza A.
have to be carefully checked in each classroom of of iterations. Secondly, experimental tests were per-
the same timeslot (i, j) to avoid overlaps. The formed, which were executed on the same computer
second one contains the number of keys (students and used the same instances to be able to directly
or teachers) in the variable array, and the last one compare the obtained results.
takes the value of the sought key (desired student or
teacher), which is to be searched into the array. 5.1 Evaluation of Complexity Theory
The body of the function performs an iterative The theoretical tests were performed to evalu-
process, which compares the sought key, continu- ate the efficiency of both the Binary and B-TREE
ously halves the search space until the desired key search
er of keys (students or teachers) in the variable array, and the last one takes the valuealgorithms. In order to be able to make a
has been found, and returns the position of the spe-
the sought key (desired student or teacher), which is to be searched into thecomparison
array. between the algorithms, they were exe-
cific
The body of the key found.
function performsIfanthe key has
iterative not which
process, been found,
compares the sought
cuted using the same values and features.
ey, continuouslythehalves
algorithm returns
the search -1, until
space indicating that the
the desired keystudent
has been found, and
turns the position
does of not
the exist
specific
in key
thatfound. if the
list. The key has not
following The theoretical evaluation of the complexity of
been found, the algo-
algorithm
hm returns -1,isindicating
the B-TREE that the student
search, doesisnot
which existininFigure
shown that list. the Binary search algorithm was performed using
6. The following
gorithm is the B-TREE search, which is shown in figure 6. Equation 2, which calculates the number of itera-
tions needed to find a sought student in the worst
case. In case of B-TREE search, Equations 3 and
4 were used to calculate the lower bound and the
upper bound, respectively.
In the experimental tests, a set of n students
was used, which corresponds to the number of stu-
dents assigned to a set of events in all classrooms
in a timeslot (i, j) at a time. The values of n were
50, 1000, and 1, 000, 000 students. In the case of
the B-TREE algorithm, the number of iterations to
find a specific student depends on the depth and the
Fig. 6.6. B-tRee
Figure B-TREE search algorithm
search algorithm amount of pointers on the tree.
he function responsible for the responsible
The function search receives a parameter,
for the which containsThe
search receives the theoretical tests in the B-TREE algorithm
ught key. Thisa value enters into an iterative process, which
parameter, which contains the sought key. This performs a search
were de-
performed using three different keys (20,
ending throughvalue
the branches of the tree, depending whether the
enters into an iterative process, which per- desired key is
1000,high-
and 1000000). Based on the iterations, the
or lower than the root node. If the sought key is found, the algorithm returns the
lower and upper bounds were calculated for each
forms a search descending through the branches
alue of the key. It returns -1 if the student or teacher has not been found. number of keys. There is a range of iterations re-
of the tree, depending whether the desired key is
higher or lower than the root node. If the sought quired to find a specific student when using the B-
Computational Results
key is found, the algorithm returns the value of the TREE algorithm. The obtained results are shown in
key. It returns -1 if the student or teacher has not Figure 7.
wo types of testing were
been found. performed to prove the efficiency and efficacy of both
The range shown in Figure 7 for each quantity
gorithms. first of all, the range of iterations required to find a specific student or
acher (sought key) was calculated theoretically. For B-tRee, equations 3 and 4 of students indicates the possible number of itera-
ere used to obtain the lower and upper bound corresponding to a search with tions required to find a specific student, which is a
certain
5 Computational Results
haracteristics, such as number of students or teachers to be searched. forfunction Binary of the input size. The range could be de-
arch, the same conditions were used to calculate the maximum number of iterations.
fined as R = UB – LB, where UB is the maximum
Two types of testing were performed to prove
econdly, experimental tests were performed, which were executed on the same com-of iterations, and LB refers to the minimum
number
the efficiency and efficacy of both algorithms. First
uter and used the same instances to be able to directly compare the obtained number
results. of iteration that can be generated by the B-
of all, the range of iterations required to find a
specific student or teacher (sought key) was calcu- TREE search according to Equations 3 and 4. It is
1 Evaluation of Complexity Theory worth mentioning that for any value of n, the value
lated theoretically. For B-TREE, equations 3 and
the theoretical tests were
4 were usedperformed
to obtaintotheevaluate
lower the
andefficiency ofBinary
of both the
upper bound R will be large if the number of pointers is small.
nd B-tRee search algorithms. In
corresponding toorder to be able
a search withtocertain
make a character- Therefore,
comparison between the the value of R decreases and remains al-
gorithms, they istics,
were executed using the same values and features.
such as number of students or teachers to most constant as the number of pointers increases.
be searched. For Binary search, the same condi- As was done with the B-TREE search, theoreti-
tions were used to calculate the maximum number cal calculations were made with the Binary search.
number of students assigned to a set of events in all classrooms in a timeslot (i, j) at a
time. the values of n were 50, 1000, and 1, 000, 000 students. In the case of the B-
tRee algorithm, the number of iterations to find a specific student depends on the
depth and the amount of pointers on the tree.
the theoretical tests in the B-tRee algorithm were performed using three different
keys (20, 1000, and 1000000). Based on the iterations, the lower and upper bounds
were calculated for each number of keys. There is a range of iterations required to
find a specificANALYSIS
B-TREE ALGORITHM COMPLEXITY student when TOusing
. . . the B-tRee algorithm. the obtained results are 259
shown in Figure 7.
the testing problems used during the experimental tests were randomly generated.
the sets of n students evaluated by both algorithms to prove their efficiency were
generated using pseudo-random numbers ranked in ascending order. each testing
problem was evaluated using both algorithms (fig. 5 and fig. 6). in the case of B-
TREE search, the experimental tests were performed using different m (m = 3, m = 4,
m = 5 and m = 30).
the experimental tests were computed using several testing problems varying the
value of n (students), where 5 ≤ n ≤ 1000. Each algorithm was executed until a sought
student was found 10,000,000 times, each testing problem was executed 30 times by
each algorithm, and the average was calculated, which is shown in Figure 9.
the comparison presented in figure 9 shows the relationship between the number
of students used and the time required to find a specific student for both algorithms.
Figure 8. Comparative
SomeFig.
changes graph
8. Comparative
were of theoretical
graph
applied of
to theoretical
the B-tRee results
results of the
B-TREE
of B-tRee
algorithm; search search
vs. Binary
variations thevs.
weresearch. Binary
value search
of m used in the tree.
According to the results shown in figure 8, it can be concluded the B-tRee search
is more efficient than Binary search for 5 ≤ n ≤ 200, due to the theoretical analysis
which demonstrated that B-tRee needs fewer iterations to find a specific student
than Binary search, working under the same conditions (number of students n, and
value of m).
Nevertheless, the exact number of iterations required for the B-TREE search will
depend on the implementation of the algorithm.
In spite of the theoretical results obtained in section 5.2, where the B-tRee search
was the most efficient algorithm, the experimental results presented in Figure 9 show
a different situation. Binary search demonstrated convincingly that it is more efficient
than any variation of B-tRee search for small ranges; in this case a range of 5 ≤ n ≤
Figure 9. Fig. 9. experimental
Experimental results: B-tRee search (applying different orders) vs. Binary search,
results: B-TREE search (applying different orders) vs. Binary search,
550≤ was
key ≤used.
50.
in spite of the theoretical results 5 ≤obtained
key ≤in50. section 5.2 that show the B-tRee
search as the most
According to theefficient algorithm,
experimental resultsfigure
shown10inshows
Figurea 9,
different
it can besituation forthe
seen that upef-
to
75 students.
ficiency Binary
of both search demonstrated
algorithms, convincingly
taking into account the threethat it is more
versions efficient
of B-tRee than
search,
anysimilar
is variation
whenof nB-tRee search
is between for 10
5 and small ranges,After
students. where1550students,
≤ n ≤ 75.the behavior of B-
tRee search (according to the number of iterations), using trees with different m, is
not uniform; it varies depending on the number of students. this is unlike the behav-
ior shown by the Binary search, which is a function of the number of students consid-
ered.
In spite of the theoretical results obtained in sec- B-TREE search with m = 5, and m = 30, demon-
tion 5.2, where the B-TREE search was the most strated itself to be more efficient than Binary search.
efficient algorithm, the experimental results pre- This study proves that B-TREE search is a very
sented in Figure 9 show a different situation. Binary efficient algorithm when it is necessary to manage
search demonstrated convincingly that it is more a lot of data. Due to this, B-TREE search and its
efficient than any variation of B-TREE search for variants are commonly used in Relational Database
small ranges; in this case a range of 5 ≤ n ≤ 50 was Management Systems to access data quickly [10,
used. 11].
In spite of the theoretical results obtained in sec- The theoretical complexity is an asymptotic
tion 5.2 that show the B-TREE search as the most complexity which is evaluated in the worst case.
efficient algorithm, Figure 10 shows a different sit- The results in Section 5.1 are justified for large val-
uation for up to 75 students. Binary search demon- ues of n. This is seen in Figure 11, where B-TREE
strated convincingly that it is more efficient than shows better performance for a value of m ≥ 5. One
any variation of B-TREE search for small ranges, of the reasons that the Binary search is more effi-
where 50 ≤ n ≤ 75. cient than B-TREE search for small ranges of stu-
In Figure 11, the student ranges increase, where dents is the number of instructions that must be
50 ≤ n ≤ 1000. For B-TREE search, trees of the or- evaluated. B-TREE requires fewer iterations, but
der 3, 5, and 30 were used. The obtained results it evaluates more instructions in each one, unlike
show a different situation when compared with Fig- Binary search, which performs a greater number of
ures 9 and 10. In this case, Binary search is not the iterations, but each iteration evaluates fewer instruc-
best algorithm. It can be observed that, unlike for tions.
small ranges, for large values of n, the m value of
the tree used in B-TREE search is important.
6 Conclusion
According to Figure 11, B-TREE search is the
best option, because it involves less computing time In conclusion, according to theoretical com-
than Binary search. It is interesting because accord- plexity of B-TREE search and Binary search, the
ing to the results for 75 < n ≤ 1000, the best option number of iterations to be evaluated is smaller in B-
is B-TREE search using a tree order 5. B-TREE TREE search than in Binary search, but the number
with a tree order 30 is a good option too because it of instructions evaluated experimentally in Binary
is more efficient than Binary search. On the con- search is smaller than B-TREE to n ¡ 200.
trary, B-TREE with a tree order 3 presents worse
Theoretically, there are two cases for B-TREE.
behavior than Binary search.
The first one generates a complete tree and the sec-
Using 5 ≤ key ≤ 50, some experimental tests ond one generates an incomplete one. In the second
were performed with the B-TREE search increas- case, due to its incompleteness, the tree depth tends
ing the order of the tree (m = 8, 9, 10, 18, 19, and to be higher than a complete one. As a result, the
20) to analyze how the order of the tree affects the number of iterations required to find a sought stu-
efficiency of the algorithm. The results are shown dent increases.
in Figure 12.
Experimental results showed that Binary search
According to Figure 12, we can conclude that is more efficient than any version of B-TREE search
increasing the tree order does not necessarily im- evaluated in this research, for less than 200 stu-
prove the algorithm efficiency, considering that the dents. However, for more than 200 students, B-
behavior of the algorithm is very similar in the six TREE demonstrated itself to be faster. The reason
cases shown for a specific range of key. for this behavior is the number of instructions to be
Contrary to their theoretical complexity re- evaluated. B-TREE requires fewer iterations, but it
ported in literature, Binary search demonstrated it- evaluates more instructions in each one. This is un-
self to be better than B-TREE search in all cases like Binary search, which performs a greater num-
on all the tests performed using a small rage of stu- ber of iterations, but it evaluates fewer instructions
dents 5 ≤ key ≤ 75. For bigger values of key > 75, per iteration.
262 Cruz Chvez M. A., Martnez Oropeza A.
Fig. 12. experimental results: B-tRee search increasing the order of the tree for 5 ≤ key ≤ 50.
Figure 12. Experimental results: B-TREE search increasing the order of the tree for 5 ≤ key ≤ 50
6 Conclusion