View on GitHub


This is the lab related content for the module CS2040C (Data structures and Algorithms)

Lab 01

Here is a pdf version of the ppt I covered during the lab. And the codes that I (skimmed through) / (demonstrated live).

content.pdf (The pdf version of the ppt shown)

vectors.cpp (in-built functions of vectors and algorithms)

strings.cpp (in-built functions of strings and algorithms)

istringstream.cpp (based on istringstream)

register.cpp (My solution to the REGISTER problem)

Challenge Questions -

Q) Given a string, check if it is a palindrome or NOT without using any kind of loops / goto / recursive statements.

Solution Use reverse(s.begin(), s.end()), where s is the string.

Q) Given a list of names, how would you sort these names in alphabetical order ?

Solution Push all the names as strings in a vector<string> V, then use sort(V.begin(), V.end())

Q) Try to do the REGISTER question using the mathematical approach, which we discussed in the lab.

Solution The above code is written by Srivastave Aaryam (one of the students)