没有合适的资源?快使用搜索试试~ 我知道了~
Advanced Topics in Java
需积分: 9 9 下载量 73 浏览量
2016-01-12
09:48:04
上传
评论
收藏 7.73MB PDF 举报
温馨提示
试读
322页
The emphasis is not on teaching advanced concepts of the Java language, per se, but rather on using Java to teach advanced programming concepts that any aspiring programmer should know. The major topics covered include elementary sorting methods (selection, insertion), searching (sequential, binary), merging, pointers (called references in Java), linked lists, stacks, queues, recursion, random numbers, files (text, binary, random access, indexed), binary trees, advanced sorting methods (heapsort, quicksort, mergesort, Shell sort), and hashing (a very fast way to search).
资源推荐
资源详情
资源评论
Kalicharan
Shelve in
Programming Languages/Java
User level:
Intermediate
www.apress.com
SOURCE CODE ONLINE
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Advanced Topics in Java
RELATED
Over the years, Java’s popularity has grown to the point where it plays an important
role in most of our lives. From laptops to data centers, game consoles to scientific
supercomputers, cell phones to the Internet, Java is everywhere! There are tons of
applications and heaps of websites that will not work unless you have Java installed,
and more are created every day. And, of course, Java is used to power what has
become the world’s most dominant mobile platform, Android.
Advanced Topics In Java teaches the algorithms and concepts that any budding
software developer should know. You’ll delve into topics such as sorting, searching,
merging, recursion, random numbers and simulation, among others. You will increase
the range of problems you can solve when you learn how to create and manipulate
versatile and popular data structures such as binary trees and hash tables.
This book assumes you have a working knowledge of basic programming
concepts such as variables, constants, assignment, selection (if..else) and looping
(while, for). It also assumes you are comfortable with writing functions and working
with arrays. If you study this book carefully and do the exercises conscientiously,
you would become a better and more agile software developer, more prepared to
code today’s applications - no matter the language.
What You’ll Learn:
• How to use some advanced algorithms, implemented in Java
• How to create, manipulate and use linked lists, stacks and queues
• How to use random numbers to program games and simulations
• How to work with files, binary trees and hash tables
• Sophisticated sorting methods such as heapsort, quicksort and mergesort
• How to implement all of the above in Java
9 781430 266198
54999
ISBN 978-1-4302-6619-8
www.allitebooks.com
v
Contents at a Glance
About the Author ���������������������������������������������������������������������������������������������������������������xiii
About the Technical Reviewers ������������������������������������������������������������������������������������������ xv
Preface ����������������������������������������������������������������������������������������������������������������������������� xvii
Chapter 1: Sorting, Searching, and Merging ■ ���������������������������������������������������������������������1
Chapter 2: Introduction to Objects ■ ����������������������������������������������������������������������������������29
Chapter 3: Linked Lists ■ ����������������������������������������������������������������������������������������������������71
Chapter 4: Stacks and Queues ■ ���������������������������������������������������������������������������������������111
Chapter 5: Recursion ■ �����������������������������������������������������������������������������������������������������143
Chapter 6: Random Numbers, Games, and Simulation ■ ��������������������������������������������������167
Chapter 7: Working with Files ■ ���������������������������������������������������������������������������������������189
Chapter 8: Introduction to Binary Trees ■ ������������������������������������������������������������������������219
Chapter 9: Advanced Sorting ■ �����������������������������������������������������������������������������������������259
Chapter 10: Hashing ■ ������������������������������������������������������������������������������������������������������287
Index ���������������������������������������������������������������������������������������������������������������������������������309
www.allitebooks.com
1
Chapter 1
Sorting, Searching, and Merging
In this chapter, we will explain the following:
How to sort a list of items using selection sort•
How to sort a list of items using insertion sort•
How to add a new item to a sorted list so that the list remains sorted•
How to sort an array of strings•
How to sort related (parallel) arrays•
How to search a sorted list using binary search•
How to search an array of strings•
How to write a program to do a frequency count of words in a passage•
How to merge two sorted lists to create one sorted list•
1.1 Sorting an Array: Selection Sort
Sorting is the process by which a set of values are arranged in ascending or descending order. There are many reasons
to sort. Sometimes we sort in order to produce more readable output (for example, to produce an alphabetical listing).
A teacher may need to sort her students in order by name or by average score. If we have a large set of values and we
want to identify duplicates, we can do so by sorting; the repeated values will come together in the sorted list.
Another advantage of sorting is that some operations can be performed faster and more efficiently with sorted
data. For example, if data is sorted, it is possible to search it using binary search—this is much faster than using a
sequential search. Also, merging two separate lists of items can be done much faster than if the lists were unsorted.
There are many ways to sort. In this chapter, we will discuss two of the “simple” methods: selection and insertion
sort. In Chapter 9, we will look at more sophisticated ways to sort. We start with selection sort.
Consider the following list of numbers stored in a Java array, num:
www.allitebooks.com
Chapter 1 ■ Sorting, SearChing, and Merging
2
Sorting num in ascending order using selection sort proceeds as follows:
1
st
pass
Find the smallest number in the entire list, from positions • 0 to 6; the smallest is 15,
found in position 4.
Interchange the numbers in positions • 0 and 4. This gives us the following:
3
rd
pass
Find the smallest number in positions • 2 to 6; the smallest is 48, found in position 5.
Interchange the numbers in positions • 2 and 5. This gives us the following:
4
th
pass
Find the smallest number in positions • 3 to 6; the smallest is 52, found in position 6.
Interchange the numbers in positions • 3 and 6. This gives us the following:
5
th
pass
Find the smallest number in positions • 4 to 6; the smallest is 57, found in position 4.
Interchange the numbers in positions • 4 and 4. This gives us the following:
2
nd
pass
Find the smallest number in positions • 1 to 6; the smallest is 33, found in position 5.
Interchange the numbers in positions • 1 and 5. This gives us the following:
www.allitebooks.com
剩余321页未读,继续阅读
资源评论
「已注销」
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功