📘
Grokking-Algorithms book
PostgreSQL
  • Content
  • Introduction to Algorithms
    • Introduction
    • Binary Search
    • Big O notation
    • Recap
  • Selection sort
    • How memory works
    • Arrays and linked lists
    • Selection sort
    • Recap
  • Recursion
    • Recursion
    • Base case and recursive case
    • The stack
    • Recap
  • Quicksort
    • Divide & conquer
    • Quicksort
    • Big O notation revisited
    • Recap
  • Hash tables
    • Hash functions
    • Use cases
    • Collisions
    • Performance
    • Recap
  • Breadth-first search
    • Introduction to graph
    • What is a graph
    • Breadth-first search
    • Implementing the graph
    • Implementing the algorithm
    • Recap
  • Dijkstra's algorithm
    • Working with Dijkstra's algorithm
    • Terminology
    • Trading for a piano
    • Negative-weight edges
    • Implementation
    • Recap
  • Greedy Algorithms
    • The classroom scheduling problem
    • The knapsack problem
    • The set-covering problem
    • NP-complete problems
    • Traveling salesperson, step by step
    • Recap
  • Dynamic programming
    • The knapsack problem
    • Knapsack problem FAQ
    • Longest common substring
    • Recap
  • K-nearest neighbors
    • Classifying oranges vs. grapefruit
    • Building a recommendations system
    • Introduction to machine learning
    • Recap
  • Where to go next
    • Trees
    • Inverted indexes
    • The Fourier transform
    • Parallel algorithms
    • MapReduce
    • Bloom filters and HyperLogLog
    • The SHA algorithms
    • Locality-sensitive hashing
    • Diffie-Hellman key exchange
    • Linear programming
    • Epilogue
  • Answers to exercises
    • Chapter 1
    • Chapter 2
    • Chapter 3
    • Chapter 4
    • Chapter 5
    • Chapter 6
    • Chapter 7
    • Chapter 8
    • Chapter 9
    • Chapter 10
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

Quicksort

PreviousRecapNextDivide & conquer

Last updated 1 year ago

Was this helpful?

  • Siz bo'l va zabt etish haqida bilib olasiz. Ba'zan siz o'rgangan hech qanday algoritm bilan hal qilib bo'lmaydigan muammoga duch kelasiz. Yaxshi algoritmist bunday muammoga duch kelganida, ular shunchaki taslim bo'lmaydilar. Ular muammoni hal qilishda foydalanadigan, yechim topishga harakat qiladigan texnikalar bilan to'la asboblar qutisiga ega. Bo'l va zabt et - bu siz o'rganadigan birinchi umumiy texnikadir.

  • Siz amaliyotda tez-tez ishlatiladigan tezkor saralash(quicksort) algoritmi haqida bilib olasiz. Quicksort bo'l va zabt etishdan foydalanadi.

Rekursiya haqida hamma narsani oxirgi bobda bilib oldingiz. Ushbu bob muammolarni hal qilish uchun yangi mahoratingizni ishlatishga qaratilgan. Biz muammolarni hal qilishning taniqli rekursiv usuli bo'lgan bo'l va zabt et (D&C) ni o'rganamiz. Ushbu bob haqiqatan ham algoritmlarning go'shtiga kiradi. Axir, algoritm faqat bitta turdagi muammolarni hal qila olsa, unchalik foydali emas. Buning o'rniga, D&C sizga muammolarni hal qilish haqida o'ylashning yangi usulini beradi. D&C asboblar qutingizdagi yana bir vositadir. Yangi muammoga duch kelganingizda, siz qotib qolishingiz shart emas. Buning o'rniga siz: "Agar men bo'l va zabt etsam, buni hal qila olamanmi?" Deb so'rashingiz mumkin.

Bobning oxirida siz birinchi asosiy D&C algoritmini bilib olasiz: tezkor tartiblash. Quicksort - bu saralash algoritmi va tanlashdan ko'ra tezroq (2-bobda o'rgangansiz). Bu oqlangan kodning yaxshi namunasidir.

Page cover image
Roman soldier