this time I've found a version of bubble sort here. I wanted to provide my version, which is less iterative and, I think, more intuitive. What it does is, simply, bubble until it's sorted:
bubblesort(L1, L2) :- bubblesort2(L1,L2,unsorted),!.
bubblesort2(L,L,sorted).
bubblesort2(L1,L2,unsorted) :- bubble(L1,L3,C), bubblesort2(L3,L2,C).
bubble([],[],sorted).
bubble([X],[X],sorted).
bubble([X,Y|L], [X|L1], C) :- X <= Y, bubble([Y|L],L1,C).
bubble([X,Y|L], [Y|L1], unsorted) :- X > Y, bubble([X|L],L1,_).
Yes, the exam is tomorrow so I will finally stop annoying you readers ;)
6 comments:
Good post thanks for share information.
SRI ANNAPOORNESHAWARI ASTROLOGY CENTER.Best Astrologer In Maryland
Pandit Ramdial Ji Famous Astrologer in Hamilton is specialized in all terms in astrology. His practice in astrology has reached many targeted issues to be resolved successfully. He advocates that many people pray to God to illuminate their life.
Famous Astrologer in Hamilton
Very good article,Thank you
DURGAANUGARHA ASTROLOGY.Best Astrologer In tumkur
Fast-track your data analytics and machine learning course with guaranteed placement opportunities. Most extensive, industry-approved experiential learning program ideal for future Data Scientists.
I thoroughly enjoyed reading your insightful article on implementing Bubble Sort for Prolog. Your clear explanations and detailed code examples make it accessible for both beginners and those looking to deepen their understanding of Prolog. The step-by-step breakdown and the incorporation of visualizations truly enhance the learning experience.
Moreover, I couldn't help but draw parallels between the structured approach in your article and the comprehensive curriculum of Imarticus Learning's Data Science Course. Just like your meticulous explanation of sorting algorithms, Imarticus Learning provides a well-structured and industry-relevant curriculum for aspiring data scientists. Their hands-on projects, expert-led sessions, and emphasis on practical applications align perfectly with the principles demonstrated in your Prolog implementation. Kudos on creating such valuable content, and it's exciting to see how it resonates with the structured learning philosophy embraced by platforms like Imarticus Learning.
I thoroughly enjoyed reading your article on implementing Bubble Sort in Prolog! Your clear explanations and step-by-step approach make it accessible for readers like me who are eager to delve into Prolog programming. The examples provided truly enhance understanding, making it a valuable resource for those looking to strengthen their Prolog skills.
Additionally, I'd like to take this opportunity to highlight the significance of upskilling in the field of data science. Imarticus Learning's Data Science Course stands out as a fantastic option for anyone seeking a comprehensive and practical education in this dynamic field. With hands-on projects, industry-relevant curriculum, and expert guidance, it offers a pathway to success in the ever-evolving world of data science. Your article not only sheds light on Prolog but also underscores the importance of staying updated with cutting-edge skills like those taught at Imarticus Learning. Keep up the excellent work!
Post a Comment