Per 2016, RMID pindah ke RMID Discord (Invite link dihapus untuk mencegah spambot -Theo @ 2019). Posting sudah tidak bisa dilakukan lagi.
Mohon maaf atas ketidaknyamanannya dan mohon kerjasamanya.
|
|
| 2011-11-30, 00:34 | [ASK] Sort n Modus |
---|
Kuro Ethernite The Creator
Posts : 1631 Thanked : 24 Engine : RMVX Ace Skill : Masterful Type : Jack of All Trades
Awards:
| Model pertanyaan yg sama with my last trit before.... Aq hanya ingin tau BEST CASE dari suatu algoritma untuk men SORTIR, dan mencari MODUS.... Semenjak mencari Modus q kira langkah terbaikny yakni mengurutkan semua nilainy trlebih dahulu, so skalian ajah.... (summon fredy ~ ) THANKS AGAIN ~ |
| | | 2011-11-30, 00:49 | Re: [ASK] Sort n Modus |
---|
Demon033 Novice
Posts : 258 Thanked : 2 Engine : Other Skill : Beginner Type : Writer
| bagusan juga pke insertion sorting (OOT ga ya?? ) |
| | | 2011-11-30, 00:51 | Re: [ASK] Sort n Modus |
---|
fredy Senior
Posts : 612 Thanked : 4 Engine : RMVX
| Copas from CB how to sort array http://www.techotopia.com/index.php/Advanced_Ruby_Arrays#Sorting_Arrays |
| | | 2011-11-30, 00:57 | Re: [ASK] Sort n Modus |
---|
Kuro Ethernite The Creator
Posts : 1631 Thanked : 24 Engine : RMVX Ace Skill : Masterful Type : Jack of All Trades
Awards:
| ya elah..... d topik ny kan aq ga menyatakan bahwa ini soal ruby... nany algoritma.... But my bad.... scara reflek q ngepos ny d sektor RGSS2 |
| | | 2011-11-30, 01:16 | Re: [ASK] Sort n Modus |
---|
fredy Senior
Posts : 612 Thanked : 4 Engine : RMVX
| Mungkin seperti ini algoritmanya Hope it help Though I'm not sure - Code:
-
#Coba misal ada array num = [3,8,10,15,7] ord[] ord[0] = num [0] #get the first minimum for i = 0..num.size if ord[0] < num[i] ord[0] = num[i] end end # determine max max = ord[0] for i = 0..num.size if num[i] > max max = num[i] end end #all except ord[0] become max temporaryly for i = 1..ord.size ord[i] = max end
#to the next for i = 1..num.size for j = 0..num.size #is current id value lower than or equal to max and not higher than previous id if ord[i] > num[j] and ord[i] <= ord[i-1] ord[i] = num[j] end end end |
| | | 2011-11-30, 01:58 | Re: [ASK] Sort n Modus |
---|
Kuro Ethernite The Creator
Posts : 1631 Thanked : 24 Engine : RMVX Ace Skill : Masterful Type : Jack of All Trades
Awards:
| Kurang ngerti... Bisa rada d jelasin dikit ?? - Code:
-
# contoh.... ngaco = [5, 7, 9, 1, 3, 2] # any largest number parah = 999 for i in 0..ngaco.size for j in i..ngaco.size if ngaco[j] < parah parah = ngaco[j] ngaco[j] = ngaco[i] ngaco[i] = parah end end end Itu punya q.... Baru aja kepikir pas copas-edit punya mu tuk coba eksekusi ~ Konsepny, dari awal ampe akhir d tlusuri untuk d cari nilai minimal ny pas ketemu, langsung d tukar dengan array pertama, n sterus ny.... itu konsep ny.... Tapi pas coba d eksekusi masih ngaco juga masih ga k sortir..... well... at least that was my opinion.... |
| | | 2011-11-30, 07:52 | Re: [ASK] Sort n Modus |
---|
hart Senior
Posts : 805 Thanked : 38 Engine : Other Skill : Very Beginner Type : Developer
| yang cepat itu Quick Sort, Merge Sort, atau Heap Sort CMIIW, tapi saya lebih suka Quick Sort karena lebih mudah implementasinya (silahkan cari aja di google ) kalau mau gampang pake .Net aja deh, perintah sortnya luar biasa amat sangat cepat. @om kuro: yang punya anda itu Bubble Sort, algoritma sorting yang paling lambat dan paling mudah. BTW punya om sedikit salah, harusnya: - Code:
-
ngaco = [5, 7, 9, 1, 3, 2] for i in 0..ngaco.size for j in i + 1..ngaco.size if ngaco[j] < ngaco[i] parah = ngaco[j] ngaco[j] = ngaco[i] ngaco[i] = parah end end end
CMIIW |
| | | 2011-11-30, 12:20 | Re: [ASK] Sort n Modus |
---|
Kuro Ethernite The Creator
Posts : 1631 Thanked : 24 Engine : RMVX Ace Skill : Masterful Type : Jack of All Trades
Awards:
| @hart g-goodness, it works.... IT WORKS !!!! u just hepl me out, hart !!!! Q kurang tau soal quick sort or bubble sort or whtaever.... Yg aq minta hanya yg paling simpel ny ~ Okay.... Let's get back to the point Now about mncari sebuah nilai yg paling sering muncul, or should I said Modus..... ini bayangan q untuk modus, and lemme know if there's something better.... - Code:
-
for i in 1..ngaco.size if i == (i-1) walah += 1 else if aduh > walah aduh = walah x = @ngaco[i] end walah = 0 end end Itu bayangan q untuk nyari modus.... Jelas keliatan ga efektif banget kalo aja ada jumlah modus yg sama.... |
| | | 2011-11-30, 14:14 | Re: [ASK] Sort n Modus |
---|
hart Senior
Posts : 805 Thanked : 38 Engine : Other Skill : Very Beginner Type : Developer
| @om kuro: wah sama2 tak kuduga bisa membantu - Quote :
- Q kurang tau soal quick sort or bubble sort or whtaever.... Yg aq minta hanya yg paling simpel ny ~
tapi kalau angkanya agak banyak (sekitar 1000 aja, belum banyak amat), bubble sort akan jadi sangat lambat.. (sampai2 anda pikir programnya hang). tapi kalau angkanya dikit sih memang gpp CMIIW BTW itu modusnya udah dicoba belum om? kalau saya lihat sih kayaknya hasilnya gak sesuai? IMO bukannya harusnya - Code:
-
for i in 1..ngaco.size if @ngaco[i] == @ngaco[i - 1] walah += 1 else if walah > aduh aduh = walah index_modus = i - 1 end walah = 0 end end bilangan_modus = ngaco[index_modus] jumlah_kemunculan = aduh
terus kalau mau bisa untuk modus lebih dari satu, di bayangan saya kayaknya tinggal bikin index_modus jadi array deh.. |
| | | 2011-11-30, 14:29 | Re: [ASK] Sort n Modus |
---|
Kuro Ethernite The Creator
Posts : 1631 Thanked : 24 Engine : RMVX Ace Skill : Masterful Type : Jack of All Trades
Awards:
| owh crap .... kburu2, jdi lupa nambahin "ngaco" ny yep, that's whta I mean.... ntar..... q bakal mikirin bbrapa hal dlu.... (somekind dapet inspirasi ) Thanks por teh hepl ~ |
| | | | Re: [ASK] Sort n Modus |
---|
Sponsored content
| | | | Halaman 1 dari 1 | |
| Permissions in this forum: | Anda tidak dapat menjawab topik
| |
| |
Latest 10 Topics | [Web Novel] Gloria Infidelis 2016-11-17, 21:27 by LightNightKnight
[Announcement] Forum baru untuk RMID 2016-08-25, 16:39 by TheoAllen
Where I'm Wrong ? 2016-07-24, 16:10 by ReydVires
flakeheartnet's Resources part III 2016-07-08, 14:30 by flakeheartnet
Keira's Art Warehouse 2016-06-28, 19:27 by KeiraBlaze
Theo Core Time System + Bingung 2016-06-27, 16:24 by Lockin
Error Script, Maybe ? 2016-06-27, 16:20 by Lockin
Nusaimoe @ RMID Lounge 2016-06-21, 05:02 by Jihad Bagas
Call Random Battle 2016-06-15, 17:04 by Lockin
Flakeheartnet Resources Part II [come back gift] 2016-06-07, 15:51 by flakeheartnet
|
Statistics
|
Members: [ 4947 ]
Topics: [ 8258 ]
Posts: [ 112606 ]
Newest member: [ https://rmid.forumotion.net/u4968 ]
|
|
|
|
|
|