Logo 
Search:

Artificial Intelligence Article

Submit Article
Comments on ProLog Program of Bubble Sort

Program to sort using Bubble Sort.


Anita Jain
Anita Jain from United StatesJun 21
why is it so?plz suggest me what to do for the given problem
Anita Jain
Anita Jain from United StatesJun 21
I've written the same code for bubble sort but it is not giving me the correct output,the list entered is given as output.
Mehwish Sheraz
Mehwish Sheraz from United KingdomFeb 28
I have used a similar code, however its only valid for numbers whereas I want to also use it for letters. What can I change in my code?
swap([X,Y|List],[Y,X|List]) :- X > Y. 	
swap([Z|List],[Z|List1]) :- swap(List,List1).
printlist([]) :- nl.
printlist([List|_]) :-
write(" ",List),
printlist(List)


Please enter your Comment
  • Comment should be atleast 15 Characters.
  • Please put code inside [Code] your code [/Code].