Advertisement
Guest User

RadhikaFunctionalProgrammingCode

a guest
Jan 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.49 KB | None | 0 0
  1. defmodule Final.Project do  
  2.    
  3.     def start_project do
  4.         IO.puts "Welcome to the project '100xAlgo' "
  5.         IO.puts "1.Bubble sort...Complexity theta(n^2)"
  6.         IO.puts "2.Quick sort...Complexity on theta(lg n)"
  7.         option = IO.gets "Please select a number corresponding to the above list"
  8.         option = option |>String.trim()
  9.                         |> String.to_integer()
  10.  
  11.         cond do
  12.             option == 1 ->
  13.                 IO.puts "Algo1:  Bubble sort   <<please input the range of input sizes that you want running times to>>"
  14.                 min = IO.gets "minimun: "
  15.                 min = min |> String.trim()
  16.                           |> String.to_integer()
  17.                 max = IO.gets "maximum: "
  18.                 max = max |> String.trim()
  19.                           |> String.to_integer()
  20.                 for x<-1..100 do                  
  21.                     input_size = (:rand.uniform((max - min) + 1)) -1 +min
  22.                    
  23.                     pid = Algo1.SubSupervisor.run_algo(input_size)
  24.            
  25.                     Final.Algo1.sort_time(pid)
  26.                    
  27.                 end
  28.  
  29.             option == 2 ->
  30.                 IO.puts "Algo2:  Quick sort   <<please input the range of input sizes that you want running times to>>"
  31.                 min = IO.gets "minimun: "
  32.                 min = min |> String.trim()
  33.                           |> String.to_integer()
  34.                 max = IO.gets "maximum: "
  35.                 max = max |> String.trim()
  36.                           |> String.to_integer()
  37.                 for x<-1..100 do                  
  38.                     input_size = (:rand.uniform((max - min) + 1)) -1 +min
  39.                    
  40.                     pid = Algo2.SubSupervisor.run_algo(input_size)
  41.            
  42.                     Final.Algo2.sort_time(pid)
  43.                    
  44.                 end
  45.  
  46.             true ->
  47.                 "start again and enter a valid option"
  48.         end
  49.  
  50.     end
  51.  
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement