C++

Insertion Sort

Download Insertion Sort // //  main.cpp //  Insertion_Sort // //  Created by Zhenlin Pei on 12/23/18. //  Copyright © 2018 Zhenlin Pei. All rights reserved. // // C program for insertion sort #include <stdio.h> #include <math.h> /* Function to sort an array using insertion sort*/ void insertionSort(int arr[], int n) {     int i,… read more »

Selection Sort

Download Selection_Sort // //  main.cpp //  Selection_Sort // //  Created by Zhenlin Pei on 12/23/18. //  Copyright © 2018 Zhenlin Pei. All rights reserved. // // C program for implementation of selection sort #include <stdio.h> void swap(int *xp, int *yp) {     int temp = *xp;     *xp = *yp;     *yp… read more »

Bubble Sort

Download Bubble_Sort Last login: Sun Dec 23 13:26:10 on ttys000 Zhenlins-MacBook-Pro:~ pei$ cd CPP/Sorting/ Zhenlins-MacBook-Pro:Sorting pei$ ls Bubble_Sort Zhenlins-MacBook-Pro:Sorting pei$ cd Bubble_Sort/ Zhenlins-MacBook-Pro:Bubble_Sort pei$ vim Bubble_Sort.cpp // Optimized implementation of Bubble sort  #include <stdio.h>  void swap(int *xp, int *yp)  {  int temp = *xp;  *xp = *yp;  *yp = temp;  }  // An optimized version… read more »

Sorting

WHAT IS AN ALGORITHM? The best definition of algorithms that I have come across is the following: Algorithms are a series of steps or rules for solving a computational problem. A computational problem is a collection of questions that computers might be able to solve. An example of a simple algorithm could be one used by a… read more »

lpthread

  : undefined reference to ‘sem_init’        

SystemC

. . . . . . Now in order to create executables run the following command based on your computer architecture (i.e. 64 bit or 32 bit) For 64 bit: (notice command is long, scroll to see more on the right) g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -o hello hello.cpp -lsystemc -lm For 32 bit:… read more »

Sidebar