Binary Search Trees as a Sorting Mechanism

linksnewsAI and Robotics

Oct 18, 2013 (3 years and 10 months ago)

94 views

Gaughran: Binary Search Trees










Binary Search Trees as a Sorting
Mechanism


Peter Gaughran

Second Computer Science and Software Engineering

SE214 Communication Skills

Technical Report

April 2005








Department of Computer Science

National University of Ireland, Maynooth

Co.

Kildare

Ireland

Gaughran: Binary Search Trees


Abstract


Searching large files of data is common in information systems. For efficiency, the
data should be sorted into a particular order on some key field so that fast search
techniques can be applied. One way of sorting records is usi
ng a binary search tree.
The records are read from the file and are inserted into the binary tree so they are in
-
order. The tree is then traversed and at each node visited the record is written to a
new, sorted file. Although effective, using a binary sear
ch tree to sort data has
disadvantages of memory use and speed over other methods such as quick sort.

Gaughran: Binary Search Trees


Contents


Chapter 1: Introduction

1.1

Data and Information Processing

................................
...............................

1

1.2

Searching Data

................................
................................
...........................

1

1.3

Sorting Data

................................
................................
...............................

2

1.4

Report Structure

................................
................................
.........................

3


Chapter 2: Sorting using a Binary

Search Tree

2.1

Binary Trees

................................
................................
...............................

4

2.2

Binary Search Trees

................................
................................
...................

5

2.3

Insertion into Binary Search Trees

................................
.............................

6

2.4

Traversal of Binary Search Trees

................................
...............................

8

2.5

Sorting strings using a Binary Search Tree

................................
................

9

2.6

Case study: Sorting the counties of Ireland

................................
.............

10


Chapter 3: Conclusions

3.1

Binary Search Tree
s as a sorting mechanism

................................
...........

11

3.2

Drawbacks of Binary Search Trees.

................................
.........................

11

3.3

Other sorting methods compared.

................................
............................

12

3.4

Conclusion

................................
................................
...............................

12


References

................................
................................
................................
.............

13


Gaughran: Binary Search Trees

1

Chapter One: Introduction


1.1

Data and Information Processing

Please note that the text included here has nothing to do with the

supposed title of this
report. It is here just to give you a style template for the preparation of your own
reports. The styles available in this document have been set up to give your report the
prescribed style, namely:



Heading 1 (for chapter titles),



H
eading 2 (for section titles),



Heading 3 (for sub
-
section titles),



Normal (for main text),



Caption (to label illustrations),



Header,



Footer, and



Page Number.


Your report should include illustrations, equations, formulae, tables and so on where
appropriate
. It is usually easiest to have each illustration, equation etc. as a paragraph
of its own, making sure the "float over text" option is
not

selected. The illustration
should be centered between the margins, as here, and can be resized if necessary by
dragg
ing the corner.


Figure 1: All illustrations should be centered and should have captions.


Gaughran: Binary Search Trees

2

Diagrams can be drawn within word (using Insert
-

Object
-

Microsoft Word Picture
menu option) using the drawing tools provided. Similarly, an equation editor is
av
ailable (using Insert
-

Object
-

Microsoft Equation menu option). All equations and
formulas should be numbered so they can be referred to in the text.


(1)

Photos and drawings already created can be imported from a

file (using Insert
-

Picture
-

From File…).


References should be given in the text at the appropriate place like this [2].. Look at
the end to see how they are to be listed.

1.2

Marking scheme

Here is the marking scheme I am using for this course.

Introdu
ction

15

Technical clarity

10

Critical Evaluation

15

Use of English

10

Use of illustrations etc.

10

General presentation of report

10

Poster

10

Oral Presentation

15

Job applications/CVs

5

Table 1: Marking scheme for SE214.

1.3 Poster Presentation

You are required to create a poster presentation summarising the material in your
technical report. Your poster presentation should be A2 size (i.e. four sheets of A4
paper). Your poster should be complete and understandable on its own. It should be
less t
ext
-
based than your report
-

summarise using bulleted points and/or short
paragraphs of text. Your poster should be legible from about a metre distance so use a
text point size of about 18 to 24. Diagrams and illustrations with appropriate captions
Gaughran: Binary Search Trees

3

are oft
en better than text. For examples of what is required, you should (critically)
look at the framed posters in the department.


The materials and equipment to mount your poster will be available on Tuesday from
1.30pm and Wednesday morning in the foyer of th
e Callan Building, namely:



Blue boards (A2 size)



Sticky velcro pads



Pritt stick glue



Guillotine



Display stands.

I will give a demonstration of mounting a poster at 1.30pm on Tuesday in the Callan
foyer. Your poster should be on display by 12noon on Wednesd
ay 3
rd

May. The
external examiner wants to see the posters so I will remove them after they have been
marked. If you want your poster back, it will be available from me after the exam
results are published.

Mounting instructions for posters

2

Take an A2 size
d blue board

3

Trim about 3mm of each edge of your four A4 sheets using the guillotine.

4

Glue your four sheets onto the blue board so the blue shows around the edge of
each sheet. Be careful that the sheets are all parallel and equally spaced.

5

Take four stick
y velcro squares of hooks and stick to each corner of the back of
the blue board.

6

Attach your completed poster to a vacant display stand
-

the hooks will cling to the
material.


You are required to give a four
-
minute presentation on the topic in your resea
rch
report. Here are a few pointers that may help you give a professional and impressive
presentation.




Be professional: have well
-
prepared slides that use colour, diagrams and text in
appropriate ways to bring your message across. I suggest you prepare yo
ur slides
Gaughran: Binary Search Trees

4

using Microsoft Powerpoint. A computer and projector will be available for you to
show these directly to the audience.



Remember, you only have four minutes so don't have too much material to
present. Practice with a clock or watch, preferably in
front of other people
(classmates), to check your talk is about the right length.



In the talk, you will be informed after three minutes that there is one minute left.
You will be cut off if you go more than a few seconds over the four
-
minute time
-
limit.



Pr
epare slides that are not overloaded with material. The slides should outline
what you are saying using phrases and diagrams rather tan being a word
-
by
-
word
script of what you say.



Don’t depend too much on your slides: your speech is the presentation and t
he
slides support you (not the other way around).



Although we only have four minutes, don't rush, take your time: pause frequently.
Sometimes, the best thing to say is nothing. Short one
-
second rests create
dramatic impact and also give your audience tim
e to assimilate what you’ve said.
Of course, you also have to maintain continuity and flow; otherwise people forget
what you are talking about. It’s a question of balance.



Arrive early and make sure you know where all the equipment is. Know how to
use it
.



Look mostly at the AUDIENCE, not at your slides or the screen behind you.



Project your voice (but don’t shout).



Smile: enjoy giving your presentation.



Be confident: you've written a report on your topic so you know what you are
talking about


here is yo
ur opportunity to show it.



The people in the audience
are
on your side (though sometimes they disguise it
well!) They want you to succeed. If they ask you a question you don’t
understand, say so and ask their help. Ask them to explain, and ask nicely.

If you
still don’t understand, don’t bluff. Admit your ignorance and suggest ways of how
you will overcome that lack of knowledge.
You are not being assessed on your
technical knowledge
-

just on your presentation and communication skills.

Gaughran: Binary Search Trees

5



Nobody knows ev
erything; but that’s no excuse for not trying to know everything.
A knowledgeable person knows enough to do his job well, a wise person knows
that he doesn’t know everything, and an intelligent person knows how to find out
what he doesn’t know. Be knowle
dgeable, wise, and intelligent in your
presentation and answers to questions.




Has the student covered all of the relevant issues?



Was the presentation clear and concise?



Was the student audible?



Did the student make effective use of audiovisual
aids?



Was

he confident of his subject matter?



Did he answer questions well (
i.e.

confidently, not
necessarily completely)?



Did the student make the subject matter interesting?

If you knew nothing about the project, would you have
learned much from the presentation?


The rest of this text is here just to give more
examples.

Hard to hear, no supporting material

0



1


Barely covered the material; uninspiring delivery

2



3


Covered the material
; audible and clear

4



5


Complete coverage; audible, clear, confident

6



7


Ditto; also made the subject interesting

8



9


Yes to all these questions.

10



Gaughran: Binary Search Trees

6

Chapter Two: Binary Trees

Automatic structuring (feature coding and object recognition) of topographic data,
such as that derived from air survey or raster scanning large
-
scale paper maps,
requir
es the classification of objects such as buildings, roads, rivers, fields and
railways. Shape and context are the main attributes used by humans. Our project
combines shape recognition techniques developed for computer vision and contextual
models derived
from statistical language theory to recognise objects. This paper
describes the measurement of shape to characterise features that will then be used as
input into a graphical language model.


Much work has been done in computer vision on the identificatio
n and classification
of objects within images. However, less progress has been made on automating
feature extraction and semantic capture in vector graphics. This is partly because the
low
-
level graphical content of maps has often been captured manually (o
n digitising
tables etc.) and the encoding of the semantic content has been seen as an extension of
this. However, the successful automation of raster
-
vector conversion plus the large
quantity of new and archived graphical data available on paper makes the

automation
of feature extraction desirable.



Feature extraction and object recognition are large research areas in the field of image
processing and computer vision. Recognition is largely based on the matching of
descriptions of shapes. Numerous shape d
escription techniques have been developed
in computer vision, such as, boundary chain coding, analysis of scalar features
(dimension, area, number of corners etc), Fourier descriptors and moment invariants.
These techniques are well understood when applied

to images and have been
developed to describe shapes irrespective of position, orientation and scale. They can
also be easily applied to vector graphical shapes.

Gaughran: Binary Search Trees

7

References

[1] H.M. Deital and P.J. Deital [1998]:
C++ How To Program
, 2
nd

edition, Prentice

Hall, 1998.

[2] L. Keyes and A.C. Winstanley [1999a]: Using Fourier Descriptors for Classifying
Shapes on Large Scale Maps,
Proceedings of the GIS Research UK 7
th

Annual
Conference
, 87
-
90, Southampton, April 1999.

[3] L. Keyes and A.C. Winstanley [1999b]:

Fourier Descriptors as a General
Classification Tool for Topographic Shapes,
IMVIP '99 Proceedings of the
Irish Machine Vision and Image Processing Conference
, 193
-
203, Dublin City
University, 1999.

[4] M. Monaghan, M.Frain and A.C. Winstanley [1999]: Ma
p Feature Recognition
Using Neural Networks,
Proceedings of the GIS Research UK 7
th

Annual
Conference
, 87
-
90, Southampton, April 1999.

[5] A.C. Winstanley [1998]: Structuring Vector Maps Using Computer Vision
Techniques,
Proceedings of the Association for

Geographic Information
Conference
, 8.11.1
-
1.11.2, Birmingham, 1998.