Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Cocktail Sort | Simple Algorithms
Sorting Algorithms
セクション 1.  7
single

single

bookCocktail Sort

メニューを表示するにはスワイプしてください

Cocktail sort is another kind of Bubble sort. In Bubble sort, we traverse the array from left to right to push the greatest element to the end of the unsorted part. In Cocktail sort, we do iterations in both directions: first move the greatest element to the right, then move the least element to the left, and then repeat it again until array is sorted.

Example 1

Time Complexity: O(N^2).

Space Complexity: O(1).

タスク

スワイプしてコーディングを開始

Follow the comments to complete the Cocktail Sort algorithm. Add missing lines to code.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  7
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt