An attempt to simplify codes as much as possible.
C++ Java Python Yacc Lex
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Intermediate code generation
Lexical analyzer
Parser for sample language


Instructions and solutions to common issues (please read) ->

Downloading 😉

  1. Say you want to download the file through the terminal, just enter in the following command:

  2. It's of the form:

    `wget URL/file.txt`
  3. Although it is worth mentioning that repos should ideally be "git clone"-d like this:

Other similar works ->

  1. BE Sem2 CL3-Codes ->

  2. TE Sem1 & Sem2 (Download link) ->

  3. SE Sem1 & Sem2 (Download link) ->


  1. Please see the link mentioned in the code to understand what's going on.

  2. To get the sequence in which cities were travelled, print out the contents of a when i==n

  3. While constructing the graph, make sure that in the matrix you plot - if a path doesn't exist from say A to B,then assign a value like 999 to that place (a large value indicates that a path does not exist between those vertices).

  4. Make sure that the initial value assigned to cost is huge compared to the costs you assign when there is no existing path between cities. For example, in the above point, we assigned 999 - so make sure your initial cost is something like 9999.


  1. Make sure the centroid you choose,belongs to one of the points.

  2. The end result of the centroids will always be same (provided the points are same of course) as the code runs till hasAchievedPerfectCentroids = true.


  1. Keep in mind, the 0/1 knapsack problem is solved using the branch and bound approach.

  2. Watch this video for a proper explanation.

LEX and YACC programs

  1. If you installed bison:

     bison -d <yacc_file>.y
     flex <lex_file>.l
     gcc lex.yy.c <yacc_file>.tab.c -lm
  2. If not:

     yacc -d <yacc_file>.y
     flex <lex_file>.l
     gcc lex.yy.c <yacc_file>.tab.c -lm