Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
アルゴリズムクイックリファレンス 第2版
by
George T. Heineman
,
Gary Pollice
,
Stanley Selkow
,
黒川 利明
,
黒川 洋
December 2016
Intermediate to advanced
440 pages
9h 44m
Japanese
O'Reilly Japan, Inc.
Content preview from
アルゴリズムクイックリファレンス 第2版
4.3
ヒープソート
■
67
void *tmp = ar[i];
ar[i] = ar[maxPos];
ar[maxPos] = tmp;
}
}
}
選択ソートは本章で述べる整列アルゴリズムの中で最も遅い。最良の場合(すな
わち、配列が既に整列されている場合)でも二乗時間かかる。ほとんど同じ作業を
一切学習せずに繰り返す。
A
の最大要素
max
の選択には、
n
−
1
回の比較が要り、
2
番目の最大要素の選択には
n
−
2
回の比較が必要なので、進歩が少ない。この比較
の多くは、無駄になっている。なぜなら、要素が
2番目
より小さいなら、最大要素
でないのだから、最大要素にはなり得ないし、
max
の計算に関係しない。この性能
が悪いアルゴリズムを詳しく述べるのはやめて、選択ソートの背後にある原則をさ
らに効果的に使えることを示す
ヒープソート
について次に述べよう。
4.3
ヒープソート
n
要素の非整列配列
A
の最大要素を見つけるには、少なくとも常に
n
−
1
回の比較
が必要だが、直接比較する要素の個数を最小化できないものだろうか。例えば、ス
ポーツのトーナメントでは、
n
個のチームから「ベスト」チームを決めるのに、優勝
者は他の
n
−
1
チームすべてと試合をするわけではない。米国で最も有名なバスケッ
トボールの試合の
1
つに、
NCAA
チャンピオンシップ・トーナメントがあるが、こ
れは、本質的には全米
64
大学のチームが競う
*
1
。最終的に優勝チームは、決勝戦に
出るまでに
5
つのチームと試合をするので、
6
回勝たないといけない。
6
=
log (
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
Rではじめるデータサイエンス
Hadley Wickham, Garrett Grolemund, 黒川 利明, 大橋 真也
プログラミングRust 第2版
Jim Blandy, Jason Orendorff, Leonora F. S. Tindall, 中田 秀基
PythonとJavaScriptではじめるデータビジュアライゼーション
Kyran Dale, 嶋田 健志, 木下 哲也
詳説 イーサネット 第2版
Charles E. Spurgeon, Joann Zimmerman, 三浦 史光, 豊沢 聡
Publisher Resources
ISBN: 9784873117850
Other