0

I want to calculate the complexity of an algorithm for which i need to mention each line of algorithm cost and frequency as a separate cell for each row of algorithm. I intend to write it in the fashion as shown at the end. I am using the algorithmic package, using it inside the tabular is giving many errors. I hope there is some way to do it.

___________________________
|1| x=0         | c | 1   |
|2| y=0         | c | 1   |
|3| for z=0 to n| c | n+1 |
---------------------------

not the duplicate of the question marked, as it says to write the algo in a column while i want each row to carry an each line of algorithm, that's why I have also added the same question in my comments for ease of understanding.

Bernard
  • 271,350
  • Please provide a minimal working example (MWE) of what you've tried so far. – CarLaTeX Sep 26 '17 at 05:16
  • what ever i tried give me error, i tried to encapsulate the algorithm with in the tabular and tried to use the algorithm each line as an element of a cell, but since it has its own tags and different line numbers so its not getting along. – Shahensha Khan Sep 26 '17 at 05:18
  • i want something like this which is also not answered :( https://tex.stackexchange.com/questions/312992/how-to-write-an-algorithm-as-a-column-inside-the-table – Shahensha Khan Sep 26 '17 at 05:19
  • It doesn't matter if your MWE doesn't work, just add it please! – CarLaTeX Sep 26 '17 at 05:19
  • Are you bound by algorithm2e or could you use another package, such as listings? – CarLaTeX Sep 26 '17 at 05:26
  • i am open to any suggestion, although my algorithm is written in algorithm2e, also a horizontal line after every row will be very nice to have. – Shahensha Khan Sep 26 '17 at 05:37
  • @ShahenshaKhan: I've added an answer to the linked post, suggesting some manual layout that should work for your use case as well. – Werner Sep 26 '17 at 05:48
  • Thanks, i checked it. Since my algorithm is a bit long, i used minipage inside a column in that case i got the algo in one column and i have two more columns. I dont know if it is a good aproach or bad but it some how full fills the requirement. Thanks for your help. if you thinks its not a good aproach let me know please. – Shahensha Khan Sep 26 '17 at 05:54
  • The listings package has \lstinline macro, and I wouldn't be surprised is other packages had something similar. You could probably just use \verb and a tabular. – John Kormylo Sep 26 '17 at 21:15

0 Answers0